Merge branch 'feature/automatic' into feature/auto_with_checkresults
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ class ResultChecker:
|
|||||||
else:
|
else:
|
||||||
print("status is ACCEPTED")
|
print("status is ACCEPTED")
|
||||||
status = ResultEnum.ACCEPTED
|
status = ResultEnum.ACCEPTED
|
||||||
# send email
|
# send email
|
||||||
try:
|
try:
|
||||||
mailer.send_email(get_accepted_result_from(reserve_pojo))
|
mailer.send_email(get_accepted_result_from(reserve_pojo))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|||||||
@@ -28,9 +28,13 @@ OTP_FIELD_ID = "#sms_code"
|
|||||||
MESSAGE_FIELD_CLASS = ".message"
|
MESSAGE_FIELD_CLASS = ".message"
|
||||||
|
|
||||||
CONFIRMED_MESSAGE = "Your request for a Leather Goods appointment has been registered"
|
CONFIRMED_MESSAGE = "Your request for a Leather Goods appointment has been registered"
|
||||||
|
CONFIRMED_MESSAGE_FR = "Votre demande de rendez-vous Maroquinerie a bien été enregistrée et nous vous en remercions."
|
||||||
DOUBLE_REQUEST_ERROR_MESSAGE = "A request with the same data has already been validated today."
|
DOUBLE_REQUEST_ERROR_MESSAGE = "A request with the same data has already been validated today."
|
||||||
|
DOUBLE_REQUEST_ERROR_MESSAGE_FR = "Une demande avec les données saisies a déjà été validée aujourd’hui."
|
||||||
TOO_MANY_REQUEST_ERROR_MESSAGE = "Due to a large number of requests"
|
TOO_MANY_REQUEST_ERROR_MESSAGE = "Due to a large number of requests"
|
||||||
|
TOO_MANY_REQUEST_ERROR_MESSAGE_FR = "Suite à un trop grand nombre de demandes aujourd’hui,"
|
||||||
CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
||||||
|
CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
||||||
TIME_OUT = 400000
|
TIME_OUT = 400000
|
||||||
OTP_TIMEOUT = 240
|
OTP_TIMEOUT = 240
|
||||||
PAGE_TIMEOUT = 40000
|
PAGE_TIMEOUT = 40000
|
||||||
@@ -114,7 +118,7 @@ class CommandorPage:
|
|||||||
otp_sent.wait_for(state='visible', timeout=TIME_OUT)
|
otp_sent.wait_for(state='visible', timeout=TIME_OUT)
|
||||||
time.sleep(get_random_wait_time())
|
time.sleep(get_random_wait_time())
|
||||||
message = self.page.content()
|
message = self.page.content()
|
||||||
if CONFIRMED_MESSAGE in message:
|
if CONFIRMED_MESSAGE in message or CONFIRMED_MESSAGE_FR in message:
|
||||||
# publish the successful message
|
# publish the successful message
|
||||||
self.logger.info("url is " + self.page.url)
|
self.logger.info("url is " + self.page.url)
|
||||||
self.publish_message_to_queue(self.contact, PublishType.SUCCESS, self.page.url)
|
self.publish_message_to_queue(self.contact, PublishType.SUCCESS, self.page.url)
|
||||||
@@ -141,7 +145,7 @@ class CommandorPage:
|
|||||||
self.browser = pwright.webkit.launch(headless=False, timeout=PAGE_TIMEOUT, proxy=proxy)
|
self.browser = pwright.webkit.launch(headless=False, timeout=PAGE_TIMEOUT, proxy=proxy)
|
||||||
self.logger.info("模拟设备: " + device)
|
self.logger.info("模拟设备: " + device)
|
||||||
pixel_2 = pwright.devices[device]
|
pixel_2 = pwright.devices[device]
|
||||||
context = self.browser.new_context(**pixel_2, locale='en-GB')
|
context = self.browser.new_context(**pixel_2, locale='fr-FR')
|
||||||
self.page = context.new_page()
|
self.page = context.new_page()
|
||||||
# hide webdriver information
|
# hide webdriver information
|
||||||
self.page.add_init_script("""() => {
|
self.page.add_init_script("""() => {
|
||||||
@@ -181,7 +185,7 @@ class CommandorPage:
|
|||||||
self.fill_fields()
|
self.fill_fields()
|
||||||
try:
|
try:
|
||||||
message = self.page.content()
|
message = self.page.content()
|
||||||
if CONFIRMED_MESSAGE in message:
|
if CONFIRMED_MESSAGE in message or CONFIRMED_MESSAGE_FR in message:
|
||||||
# publish the successful message
|
# publish the successful message
|
||||||
self.publish_message_to_queue(self.contact, PublishType.SUCCESS, self.page.url)
|
self.publish_message_to_queue(self.contact, PublishType.SUCCESS, self.page.url)
|
||||||
self.get_errors()
|
self.get_errors()
|
||||||
@@ -242,13 +246,13 @@ class CommandorPage:
|
|||||||
self.logger.error(ext)
|
self.logger.error(ext)
|
||||||
|
|
||||||
def _handle_errors(self, erro_content: str):
|
def _handle_errors(self, erro_content: str):
|
||||||
if DOUBLE_REQUEST_ERROR_MESSAGE in erro_content:
|
if DOUBLE_REQUEST_ERROR_MESSAGE in erro_content or DOUBLE_REQUEST_ERROR_MESSAGE_FR in erro_content:
|
||||||
# this email has been already used
|
# this email has been already used
|
||||||
if not self.is_finished:
|
if not self.is_finished:
|
||||||
params.oracle_log_sender.send_double_data_error(self.contact)
|
params.oracle_log_sender.send_double_data_error(self.contact)
|
||||||
self.is_finished = True
|
self.is_finished = True
|
||||||
self.termine()
|
self.termine()
|
||||||
elif TOO_MANY_REQUEST_ERROR_MESSAGE in erro_content:
|
elif TOO_MANY_REQUEST_ERROR_MESSAGE in erro_content or TOO_MANY_REQUEST_ERROR_MESSAGE_FR in erro_content:
|
||||||
# this email has been already used
|
# this email has been already used
|
||||||
if not self.is_finished:
|
if not self.is_finished:
|
||||||
definitions.local_db_manager.insert_or_update(
|
definitions.local_db_manager.insert_or_update(
|
||||||
@@ -256,7 +260,7 @@ class CommandorPage:
|
|||||||
params.oracle_log_sender.send_too_many_error(self.contact)
|
params.oracle_log_sender.send_too_many_error(self.contact)
|
||||||
self.is_finished = True
|
self.is_finished = True
|
||||||
self.termine()
|
self.termine()
|
||||||
elif CAPTCHA_ERROR_MESSAGE in erro_content:
|
elif CAPTCHA_ERROR_MESSAGE in erro_content or CAPTCHA_ERROR_MESSAGE_FR in erro_content:
|
||||||
# this email has been already used
|
# this email has been already used
|
||||||
self.is_captcha_in_error = True
|
self.is_captcha_in_error = True
|
||||||
if not self.is_finished:
|
if not self.is_finished:
|
||||||
|
|||||||
Reference in New Issue
Block a user