read mail after request

This commit is contained in:
2024-03-21 17:26:42 +01:00
parent dead188a69
commit 9a238eb642
3 changed files with 17 additions and 11 deletions
+14 -9
View File
@@ -70,6 +70,7 @@ class AppointmentRequestSender(threading.Thread):
self.contact_list = sub_contact_list self.contact_list = sub_contact_list
self.queue_name = queue_name self.queue_name = queue_name
self.proxy_to_use_list = proxy_to_use_list self.proxy_to_use_list = proxy_to_use_list
self.already_read_emails = False
def set_up_connection(self): def set_up_connection(self):
self.connection = pika.BlockingConnection( self.connection = pika.BlockingConnection(
@@ -193,12 +194,16 @@ class AppointmentRequestSender(threading.Thread):
self.channel.start_consuming() self.channel.start_consuming()
def retreive_invalidate_urls(self): def retreive_invalidate_urls(self):
self.logger.info("will retreive_invalidate_urls") if not self.already_read_emails:
_mail_list = MONGO_STORE_MANAGER.get_destination_emails() self.logger.info("will retreive_invalidate_urls")
_mail_list_filtred = [] _mail_list = MONGO_STORE_MANAGER.get_destination_emails()
for mail in _mail_list: _mail_list_filtred = []
for _contact in self.list_to_retrieve_mails: for mail in _mail_list:
if _contact.mail == mail.mail: for _contact in self.list_to_retrieve_mails:
_mail_list_filtred.append(mail) if _contact.mail == mail.mail:
self.logger.info("will call find_links_to_validate_from_mail_list, size = " + str(len(_mail_list_filtred))) _mail_list_filtred.append(mail)
find_links_to_validate_from_mail_list(_mail_list_filtred) self.logger.info("will call find_links_to_validate_from_mail_list, size = " + str(len(_mail_list_filtred)))
find_links_to_validate_from_mail_list(_mail_list_filtred)
self.already_read_emails = True
else:
self.logger.info("already read emails, will not retreive_invalidate_urls")
+2 -2
View File
@@ -64,10 +64,10 @@ def send_appointment_request(message_queue_name, _contact_list):
if __name__ == '__main__': if __name__ == '__main__':
contacts_file_path = '~/Desktop/contact_list_2024-03-20.xlsx' contacts_file_path = '~/Desktop/contact_list_2024-03-19.xlsx'
_contact_list = read_contacts(contacts_file_path) _contact_list = read_contacts(contacts_file_path)
_contact_list_to_book = filter_contacts(_contact_list) _contact_list_to_book = filter_contacts(_contact_list)
_segment_number = 2 _segment_number = 1
logger.info("{} contacts to book".format(len(_contact_list_to_book))) logger.info("{} contacts to book".format(len(_contact_list_to_book)))
last_thread = None last_thread = None
for i in range(0, _segment_number): for i in range(0, _segment_number):
+1
View File
@@ -94,6 +94,7 @@ class Sender:
self.logger.info("body in json:{}".format(json.dumps(self.received_dict))) self.logger.info("body in json:{}".format(json.dumps(self.received_dict)))
self.cookiesPublisher.publish_body(json.dumps(self.received_dict)) self.cookiesPublisher.publish_body(json.dumps(self.received_dict))
# self.cookie_str = new_coolies_str # self.cookie_str = new_coolies_str
self.logger.info("successful request, mail:{}".format(contact.mail))
return RequestResult.SUCCESS return RequestResult.SUCCESS
else: else:
print(response.text) print(response.text)