can check results in one thread
This commit is contained in:
+25
-15
@@ -13,6 +13,7 @@ from logs.LogSender import TYPE_EVENT_CHECK_RESULTS, LOG_SUBJECT_EVENT
|
||||
from pojo.ReserveResultPojo import ReserveResultPojo, PublishType
|
||||
|
||||
SORRY_SENTENCE = "nous sommes sincèrement désolés de n'avoir pu vous satisfaire cette fois-ci"
|
||||
NOT_AVAILABLE_CONTENT = "For more than 130 years, our House has offered its full expertise to satisfy"
|
||||
PENDING_SENTENCE = "Ce soir, entre 20:00 et 20:30, vous obtiendrez une réponse par e-mail."
|
||||
|
||||
|
||||
@@ -74,7 +75,7 @@ class ResultChecker:
|
||||
"password": params.PROXY_PASSWORD
|
||||
}
|
||||
while content is None:
|
||||
content = self.load_page(self.tls.playwright, url, proxy)
|
||||
content = self.load_page(self.tls.playwright, proxy, url)
|
||||
random_id_number = get_random_id_number_for_proxy()
|
||||
proxy_username = "panleicim-res-fr-" + random_id_number
|
||||
print("proxy_username is " + proxy_username)
|
||||
@@ -93,6 +94,9 @@ class ResultChecker:
|
||||
elif PENDING_SENTENCE in content:
|
||||
print("status is PENDING")
|
||||
status = ResultEnum.PENDING
|
||||
elif NOT_AVAILABLE_CONTENT in content:
|
||||
print("status is REFUSED")
|
||||
status = ResultEnum.REFUSED
|
||||
else:
|
||||
print("status is ACCEPTED")
|
||||
status = ResultEnum.ACCEPTED
|
||||
@@ -104,20 +108,26 @@ if __name__ == '__main__':
|
||||
# get the list
|
||||
params.oracle_log_sender.send_log(msg="开始检查约会结果", subject=LOG_SUBJECT_EVENT, type=TYPE_EVENT_CHECK_RESULTS)
|
||||
db_manager = params.firebase_store_manager
|
||||
collection = db_manager.get_all_successful_items_for_day()
|
||||
collection = db_manager.get_all_successful_items_for_day("2022-05-14", "landd")
|
||||
count = 0
|
||||
result_pojo = ReserveResultPojo(type=PublishType.SUCCESS, phone="0649614591", email="panleicim@gmail.com",
|
||||
message="SUCCESS", firstName="Lei", lastName="PAN", url='https://api.ipify.org')
|
||||
# result_pojo = ReserveResultPojo(type=PublishType.SUCCESS, phone="0649614591", email="panleicim@gmail.com",
|
||||
# message="SUCCESS", firstName="Lei", lastName="PAN", url='https://api.ipify.org')
|
||||
result_list = []
|
||||
# for appointment in collection.stream():
|
||||
# reserve_pojo = ReserveResultPojo.from_firestore_dict(appointment.to_dict())
|
||||
result_list.append(result_pojo)
|
||||
for appointment in collection.stream():
|
||||
reserve_pojo = ReserveResultPojo.from_firestore_dict(appointment.to_dict())
|
||||
result_list.append(reserve_pojo)
|
||||
# result_list.append(result_pojo)
|
||||
for result in result_list:
|
||||
if result.accepted is None or ResultEnum.ACCEPTED.value == result.accepted:
|
||||
ResultChecker().run(result, collection)
|
||||
else:
|
||||
print("status is " + result.accepted)
|
||||
|
||||
with ThreadPoolExecutor(max_workers=2) as executor:
|
||||
for reserve in result_list:
|
||||
count = count + 1
|
||||
if reserve.accepted:
|
||||
print("status is " + reserve.accepted)
|
||||
if reserve.accepted is None or ResultEnum.PENDING.value == reserve.accepted:
|
||||
executor.submit(ResultChecker().run, reserve, collection)
|
||||
print(count)
|
||||
# with ThreadPoolExecutor(max_workers=1) as executor:
|
||||
# for reserve in result_list:
|
||||
# count = count + 1
|
||||
# if reserve.accepted:
|
||||
# print("status is " + reserve.accepted)
|
||||
# if reserve.accepted is None or ResultEnum.PENDING.value == reserve.accepted:
|
||||
# executor.submit(ResultChecker().run, reserve, collection)
|
||||
# print(count)
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
[DEFAULT]
|
||||
contact_list_file = /Users/panlei/IdeaProjects/appointment_tool/contact_all.xlsx
|
||||
firebase_config_file = /Users/panlei/IdeaProjects/appointment_tool/appointment.json
|
||||
contact_list_file = ./contact_all.xlsx
|
||||
firebase_config_file = ./appointment.json
|
||||
LOGS_DIR = ./
|
||||
+1
-1
@@ -35,7 +35,7 @@ class DataManager:
|
||||
def get_all_successful_items_for_day(self, day, source_from: Union[str, None]):
|
||||
doc_ref = self._db.collection(day)
|
||||
if source_from is not None:
|
||||
doc_ref.where()
|
||||
doc_ref.where(u'source_from', u'==', source_from)
|
||||
return doc_ref
|
||||
|
||||
def save_sim_info(self, sim_info: SimInfoPojo):
|
||||
|
||||
Reference in New Issue
Block a user