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"
|
TYPE_SMS_RECEIVED = "TYPE_SMS_RECEIVED"
|
||||||
LOG_ERROR = "ERROR"
|
LOG_ERROR = "ERROR"
|
||||||
LOG_TYPE_INFO = "INFO"
|
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_ERROR = "APPOINTMENT_ERROR"
|
||||||
LOG_APPOINTMENT_TIMEOUT = "TIMEOUT"
|
LOG_APPOINTMENT_TIMEOUT = "TIMEOUT"
|
||||||
LOG_APPOINTMENT_CONTACT_NOT_FOUND = "CONTACT_NOT_FOUND"
|
LOG_APPOINTMENT_CONTACT_NOT_FOUND = "CONTACT_NOT_FOUND"
|
||||||
@@ -67,6 +70,14 @@ class LogSender:
|
|||||||
self._identity = oci.identity.IdentityClient(self._config)
|
self._identity = oci.identity.IdentityClient(self._config)
|
||||||
self._loggingingestion_client = LoggingClient(self._config, timeout=60.0, retry_strategy=custom_retry_strategy)
|
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):
|
def send_appoint_result(self, result: ReserveResultPojo):
|
||||||
if result.type == PublishType.SUCCESS:
|
if result.type == PublishType.SUCCESS:
|
||||||
# get id
|
# get id
|
||||||
|
|||||||
+11
-10
@@ -20,14 +20,15 @@ class ExcelHelper:
|
|||||||
contact_dict_list = json.loads(contact_list_in_json)
|
contact_dict_list = json.loads(contact_list_in_json)
|
||||||
contact_list = []
|
contact_list = []
|
||||||
for contact_dict in contact_dict_list:
|
for contact_dict in contact_dict_list:
|
||||||
raw_name = contact_dict['name'].strip()
|
if contact_dict['name']:
|
||||||
name = raw_name.split(' ')
|
raw_name = contact_dict['name'].strip()
|
||||||
last_name = name[0]
|
name = raw_name.split(' ')
|
||||||
first_name = name[-1]
|
last_name = name[0]
|
||||||
contact = ContactPojo(phone_number=contact_dict['phone'],
|
first_name = name[-1]
|
||||||
last_name=last_name,
|
contact = ContactPojo(phone_number=contact_dict['phone'],
|
||||||
first_name=first_name,
|
last_name=last_name,
|
||||||
passport_number=contact_dict['passport'],
|
first_name=first_name,
|
||||||
mail=contact_dict['email'])
|
passport_number=contact_dict['passport'],
|
||||||
contact_list.append(contact)
|
mail=contact_dict['email'])
|
||||||
|
contact_list.append(contact)
|
||||||
return contact_list
|
return contact_list
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ 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"
|
||||||
|
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
|
TIME_OUT = 400000
|
||||||
OTP_TIMEOUT = 240
|
OTP_TIMEOUT = 240
|
||||||
|
|
||||||
@@ -152,7 +154,7 @@ class CommandorPage:
|
|||||||
if CONFIRMED_MESSAGE in message:
|
if CONFIRMED_MESSAGE 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.getErrors()
|
self.get_errors()
|
||||||
|
|
||||||
def on_document_loaded(self):
|
def on_document_loaded(self):
|
||||||
print("on_document_loaded called")
|
print("on_document_loaded called")
|
||||||
@@ -191,16 +193,32 @@ class CommandorPage:
|
|||||||
except Exception as error:
|
except Exception as error:
|
||||||
self.logger.error(error)
|
self.logger.error(error)
|
||||||
|
|
||||||
def getErrors(self):
|
def get_errors(self):
|
||||||
# send error result
|
# send error result
|
||||||
self.publish_message_to_queue(self.contact, PublishType.ERROR, self.page.url)
|
self.publish_message_to_queue(self.contact, PublishType.ERROR, self.page.url)
|
||||||
try:
|
try:
|
||||||
items = self.page.query_selector("div.alert")
|
items = self.page.query_selector("div.alert")
|
||||||
if items:
|
if items:
|
||||||
print(items.inner_html())
|
erro_content = items.inner_html()
|
||||||
|
print("错误:" + erro_content)
|
||||||
|
self._handle_errors(erro_content)
|
||||||
except Exception as ext:
|
except Exception as ext:
|
||||||
self.logger.error(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):
|
def _set_email(self, email):
|
||||||
time.sleep(get_random_wait_time())
|
time.sleep(get_random_wait_time())
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user