optimization on email reader
This commit is contained in:
@@ -5,10 +5,6 @@ from src.mail.mail_reader import read_mails
|
|||||||
|
|
||||||
|
|
||||||
def start_check_mail_job(sched):
|
def start_check_mail_job(sched):
|
||||||
# sched.add_job(start_book_appointment, 'cron', day_of_week='mon-sat', hour='10',
|
|
||||||
# minute='30',
|
|
||||||
# misfire_grace_time=10,
|
|
||||||
# second='0', timezone='Europe/Paris', max_instances=1)
|
|
||||||
sched.add_job(read_mails, 'cron', day_of_week='mon-sat', hour='11',
|
sched.add_job(read_mails, 'cron', day_of_week='mon-sat', hour='11',
|
||||||
minute='30',
|
minute='30',
|
||||||
misfire_grace_time=10,
|
misfire_grace_time=10,
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ def start_book_appointment():
|
|||||||
|
|
||||||
|
|
||||||
def start_check_results_job(sched):
|
def start_check_results_job(sched):
|
||||||
# sched.add_job(start_book_appointment, 'cron', day_of_week='mon-sat', hour='10',
|
|
||||||
# minute='30',
|
|
||||||
# misfire_grace_time=10,
|
|
||||||
# second='0', timezone='Europe/Paris', max_instances=1)
|
|
||||||
sched.add_job(check_results, 'cron', day_of_week='mon-sat', hour='20',
|
sched.add_job(check_results, 'cron', day_of_week='mon-sat', hour='20',
|
||||||
minute='55',
|
minute='55',
|
||||||
misfire_grace_time=10,
|
misfire_grace_time=10,
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ def need_to_valid_url(url: str, successful_items) -> bool:
|
|||||||
id = parts[5]
|
id = parts[5]
|
||||||
if len(id) == 6:
|
if len(id) == 6:
|
||||||
for item in successful_items:
|
for item in successful_items:
|
||||||
if item.url_validated is not None:
|
# if item.url_validated is not None:
|
||||||
print("id:{}, status:{} ".format(id, str(item.url_validated)))
|
# print("id:{}, status:{} ".format(id, str(item.url_validated)))
|
||||||
if item.id == id:
|
if item.id == id:
|
||||||
if item.url_validated is not None:
|
if item.url_validated is not None:
|
||||||
return not item.url_validated
|
return not item.url_validated
|
||||||
@@ -146,9 +146,9 @@ def read_mails():
|
|||||||
# mail_address4 = MailAddress(mail="hongjiang176@aol.com", password="ftzpscgzvwneelmn")
|
# mail_address4 = MailAddress(mail="hongjiang176@aol.com", password="ftzpscgzvwneelmn")
|
||||||
# mail_list = [mail_address3, mail_address2, mail_address1, mail_address4]
|
# mail_list = [mail_address3, mail_address2, mail_address1, mail_address4]
|
||||||
# mail_list = [mail_address1]
|
# mail_list = [mail_address1]
|
||||||
|
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||||
for mail in mail_list:
|
for mail in mail_list:
|
||||||
mail_reader = MailReader(mail.mail, mail.password)
|
mail_reader = MailReader(mail.mail, mail.password)
|
||||||
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
|
||||||
mail_info_list = mail_reader.read_emails()
|
mail_info_list = mail_reader.read_emails()
|
||||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||||
for mail in mail_info_list:
|
for mail in mail_info_list:
|
||||||
|
|||||||
@@ -204,5 +204,5 @@ if __name__ == '__main__':
|
|||||||
save_mails_to_db()
|
save_mails_to_db()
|
||||||
# for mail in excel_reader.read_mails_and_pwd():
|
# for mail in excel_reader.read_mails_and_pwd():
|
||||||
# MONGO_STORE_MANAGER.insert_email(mail)
|
# MONGO_STORE_MANAGER.insert_email(mail)
|
||||||
# for i in range(1,20):
|
# for i in range(1,2):
|
||||||
# print(get_random_phone_numbers())
|
# print(get_random_phone_numbers())
|
||||||
Reference in New Issue
Block a user