log double data error and too many requests error
This commit is contained in:
@@ -23,6 +23,9 @@ TYPE_EVENT_CHANGE_SLOT = "EVENT_CHANGE_SLOT"
|
||||
TYPE_SMS_RECEIVED = "TYPE_SMS_RECEIVED"
|
||||
LOG_ERROR = "ERROR"
|
||||
LOG_TYPE_INFO = "INFO"
|
||||
LOG_ERROR_TYPE_DOUBLE_DATA = "DOUBLE_REQUEST_FOR_SAME_DATA"
|
||||
LOG_ERROR_TOO_MANY_REQUEST_TODAY = "TOO_MANY_REQUEST_TODAY"
|
||||
LOG_SUBJECT_ERROR = "ERROR"
|
||||
LOG_APPOINTMENT_ERROR = "APPOINTMENT_ERROR"
|
||||
LOG_APPOINTMENT_TIMEOUT = "TIMEOUT"
|
||||
LOG_APPOINTMENT_CONTACT_NOT_FOUND = "CONTACT_NOT_FOUND"
|
||||
@@ -67,6 +70,14 @@ class LogSender:
|
||||
self._identity = oci.identity.IdentityClient(self._config)
|
||||
self._loggingingestion_client = LoggingClient(self._config, timeout=60.0, retry_strategy=custom_retry_strategy)
|
||||
|
||||
def send_double_data_error(self, contact: ContactPojo):
|
||||
error_msg = contact.mail
|
||||
self.send_log(msg=error_msg, type=LOG_ERROR_TYPE_DOUBLE_DATA, subject=LOG_SUBJECT_ERROR)
|
||||
|
||||
def send_too_many_error(self, contact: ContactPojo):
|
||||
error_msg = contact.mail
|
||||
self.send_log(msg=error_msg, type=LOG_ERROR_TOO_MANY_REQUEST_TODAY, subject=LOG_SUBJECT_ERROR)
|
||||
|
||||
def send_appoint_result(self, result: ReserveResultPojo):
|
||||
if result.type == PublishType.SUCCESS:
|
||||
# get id
|
||||
|
||||
@@ -20,6 +20,7 @@ class ExcelHelper:
|
||||
contact_dict_list = json.loads(contact_list_in_json)
|
||||
contact_list = []
|
||||
for contact_dict in contact_dict_list:
|
||||
if contact_dict['name']:
|
||||
raw_name = contact_dict['name'].strip()
|
||||
name = raw_name.split(' ')
|
||||
last_name = name[0]
|
||||
|
||||
@@ -22,6 +22,8 @@ OTP_FIELD_ID = "#sms_code"
|
||||
MESSAGE_FIELD_CLASS = ".message"
|
||||
|
||||
CONFIRMED_MESSAGE = "Your request for a Leather Goods appointment has been registered"
|
||||
DOUBLE_REQUEST_ERROR_MESSAGE = "A request with the same data has already been validated today."
|
||||
TOO_MANY_REQUEST_ERROR_MESSAGE = "Due to a large number of requests"
|
||||
TIME_OUT = 400000
|
||||
OTP_TIMEOUT = 240
|
||||
|
||||
@@ -152,7 +154,7 @@ class CommandorPage:
|
||||
if CONFIRMED_MESSAGE in message:
|
||||
# publish the successful message
|
||||
self.publish_message_to_queue(self.contact, PublishType.SUCCESS, self.page.url)
|
||||
self.getErrors()
|
||||
self.get_errors()
|
||||
|
||||
def on_document_loaded(self):
|
||||
print("on_document_loaded called")
|
||||
@@ -191,16 +193,32 @@ class CommandorPage:
|
||||
except Exception as error:
|
||||
self.logger.error(error)
|
||||
|
||||
def getErrors(self):
|
||||
def get_errors(self):
|
||||
# send error result
|
||||
self.publish_message_to_queue(self.contact, PublishType.ERROR, self.page.url)
|
||||
try:
|
||||
items = self.page.query_selector("div.alert")
|
||||
if items:
|
||||
print(items.inner_html())
|
||||
erro_content = items.inner_html()
|
||||
print("错误:" + erro_content)
|
||||
self._handle_errors(erro_content)
|
||||
except Exception as ext:
|
||||
self.logger.error(ext)
|
||||
|
||||
def _handle_errors(self, erro_content: str):
|
||||
if DOUBLE_REQUEST_ERROR_MESSAGE in erro_content:
|
||||
# this email has been already used
|
||||
params.oracle_log_sender.send_double_data_error(self.contact)
|
||||
# close browser
|
||||
time.sleep(2)
|
||||
self.browser.close()
|
||||
elif TOO_MANY_REQUEST_ERROR_MESSAGE in erro_content:
|
||||
# this email has been already used
|
||||
params.oracle_log_sender.send_too_many_error(self.contact)
|
||||
# close browser
|
||||
time.sleep(2)
|
||||
self.browser.close()
|
||||
|
||||
def _set_email(self, email):
|
||||
time.sleep(get_random_wait_time())
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user