diff --git a/src/mail/mail_reader_all_contacts.py b/src/mail/mail_reader_all_contacts.py index f90cbbc..0a1d913 100755 --- a/src/mail/mail_reader_all_contacts.py +++ b/src/mail/mail_reader_all_contacts.py @@ -13,6 +13,7 @@ from src.db.mongo_manager import MONGO_STORE_MANAGER from src.logs.AppLogging import init_logger from src.mail.mail_constants import DOMAIN_HOTMAIL, create_imap from src.pojo.mail.mail_pojo import MailPojo +from src.utils import excel_reader from src.utils.timeutiles import is_time_between VALIDATION_URL_SUBJECT_fr = 'Validation de votre demande de rendez-vous' @@ -253,11 +254,12 @@ def need_to_check_email(mail: str, successful_items) -> bool: # return False -def read_all_mails(): +def read_all_mails(contact_to_book_list=None): # check time before start checking emails if is_time_between(time(7, 30), time(19, 30)): # get email address - contact_to_book_list = MONGO_STORE_MANAGER.get_all_contact_to_book_list() + if contact_to_book_list is None: + contact_to_book_list = MONGO_STORE_MANAGER.get_all_contact_to_book_list() mail_list = MONGO_STORE_MANAGER.get_destination_emails() mail_list_to_check = [] for contact in contact_to_book_list: @@ -305,4 +307,7 @@ def read_all_mails(): # check whether the url has already been clicked if __name__ == '__main__': init_logger() + # contact_to_book_list = excel_reader.read_contacts( + # file_name="/Users/panlei/Desktop/contact_list_2024-06-28_4000.xlsx") + # read_all_mails(contact_to_book_list=contact_to_book_list) read_all_mails() diff --git a/src/person_name/contact_manager.py b/src/person_name/contact_manager.py index 22506ec..31029be 100755 --- a/src/person_name/contact_manager.py +++ b/src/person_name/contact_manager.py @@ -1,8 +1,9 @@ import datetime import random +from pathlib import Path import xlsxwriter -from src.person_name.cython_extract_methods import filter_already_validated_contacts, read_pinyin_list_from_file +# from src.person_name.cython_extract_methods import filter_already_validated_contacts, read_pinyin_list_from_file from src.db.mongo_manager import MONGO_STORE_MANAGER from src.pojo.contact_pojo import ContactPojo @@ -13,7 +14,7 @@ DEFAULT_SERIAL = "47e7e36b" def upload_contacts_list(): - _contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-09-28.xlsx") + _contacts_to_book = read_contacts(str(Path.home()) + "/Desktop/contact_list_2024-10-03.xlsx") return _contacts_to_book @@ -203,14 +204,14 @@ if __name__ == '__main__': # contacts_to_book = upload_contacts_list() # MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book) # print("start at {}".format(datetime.datetime.now())) - generate_valid_contact_list_for_day(segment_number=2) + # generate_valid_contact_list_for_day(segment_number=2) # generate_contact_from_mail_list("/Users/lpan/Downloads/邮箱及密码.xlsx") # print("end at {}".format(datetime.datetime.now())) # update_contact_list_not_received_mail() # generate_valid_contact_list_for_day(segment_number=2) # get_old_validated_contact_list() # print("end at {}".format(datetime.datetime.now())) - # generate_all_contact_list() + generate_all_contact_list() # merge_contact_list_files( # ["/Users/lpan/Desktop/contact_list_all_old_not_used_contact.xlsx", # "/Users/lpan/Desktop/contact_list_2024-06-26.xlsx"]) diff --git a/src/pojo/contact_pojo.py b/src/pojo/contact_pojo.py index e7fa7a4..fd11341 100644 --- a/src/pojo/contact_pojo.py +++ b/src/pojo/contact_pojo.py @@ -49,7 +49,8 @@ class ContactPojo: u'store': self.store, u'ip_country': self.ip_country, u'current_ip': self.current_ip, - u'ua': self.ua + u'ua': self.ua, + u'serial': self.serial } return dest @@ -80,5 +81,8 @@ class ContactPojo: result.ip_country = ip_country if source.get('current_ip'): result.current_ip = source['current_ip'] + if source.get('serial'): + serial = source['serial'] + result.serial = serial result.ua = ua return result diff --git a/src/utils/excel_reader.py b/src/utils/excel_reader.py index 9c784e8..b249193 100755 --- a/src/utils/excel_reader.py +++ b/src/utils/excel_reader.py @@ -58,6 +58,9 @@ def read_contacts(file_name) -> list: first_name=first_name, passport_number=contact_dict['passport'], mail=contact_dict['email'], store=store) + if contact_dict.get('serial') is not None: + serial = contact_dict['serial'] + contact.serial = serial contact.ip_country = ip_country contact.ua = ua contact_list.append(contact)