diff --git a/Info.plist b/Info.plist new file mode 100644 index 0000000..e69de29 diff --git a/appointment.spec b/appointment.spec index 231f308..7ce8e5c 100644 --- a/appointment.spec +++ b/appointment.spec @@ -8,7 +8,7 @@ a = Analysis( ['appointment.py'], pathex=[], binaries=[], - datas=[], + datas=[('appointment.json','.')], hiddenimports=[], hookspath=[], hooksconfig={}, @@ -49,7 +49,6 @@ coll = COLLECT( name='appointment', ) import shutil -shutil.copyfile('./appointment.json', '{0}/appointment.json'.format(DISTPATH)) shutil.copyfile('./contact_all.xlsx', '{0}/contact_all.xlsx'.format(DISTPATH)) shutil.copyfile('./config.ini', '{0}/config.ini'.format(DISTPATH)) #shutil.copytree('./venv/Lib/site-packages/grpc/_cython/_credentials', '{0}/appointment/grpc/_cython/_credentials'.format(DISTPATH)) \ No newline at end of file diff --git a/appointment_mac.spec b/appointment_mac.spec index ddb9e2c..e02fd55 100644 --- a/appointment_mac.spec +++ b/appointment_mac.spec @@ -8,7 +8,7 @@ a = Analysis( ['appointment.py'], pathex=[], binaries=[], - datas=[], + datas=[('appointment.json','.')], hiddenimports=[], hookspath=[], hooksconfig={}, @@ -49,7 +49,6 @@ coll = COLLECT( name='appointment', ) import shutil -shutil.copyfile('./appointment.json', '{0}/appointment.json'.format(DISTPATH)) shutil.copyfile('./contact_all.xlsx', '{0}/contact_all.xlsx'.format(DISTPATH)) shutil.copyfile('./config.ini', '{0}/config.ini'.format(DISTPATH)) shutil.copytree('./venv/lib/python3.8/site-packages/grpc/_cython/_credentials', '{0}/appointment/grpc/_cython/_credentials'.format(DISTPATH)) \ No newline at end of file diff --git a/definitions.py b/definitions.py index 60e3b74..f78f754 100644 --- a/definitions.py +++ b/definitions.py @@ -1,13 +1,18 @@ import configparser import os import getpass +from pathlib import Path +home = str(Path.home()) config = configparser.ConfigParser() -config.read('./config.ini') +print("home path: " + home) +# check the config file exsistence +config_file_path = home + "/config.ini" +config.read(config_file_path) CONTACT_LIST_FILE = config['DEFAULT']['contact_list_file'] FIREBASE_CONFIG_FILE = config['DEFAULT']['firebase_config_file'] LOGS_DIR = config['DEFAULT']['LOGS_DIR'] username = getpass.getuser() -LOG_SOURCE = username +LOG_SOURCE = "Macbookpro13" ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/pojo/ReserveResultPojo.py b/pojo/ReserveResultPojo.py index 63586c8..5c6b23f 100644 --- a/pojo/ReserveResultPojo.py +++ b/pojo/ReserveResultPojo.py @@ -10,6 +10,7 @@ import definitions class PublishType(Enum): SUCCESS = "SUCCESS" ERROR = "ERROR" + PENDING = "PENDING" @dataclass_json diff --git a/workers/commandor_page.py b/workers/commandor_page.py index 87d7107..626434a 100644 --- a/workers/commandor_page.py +++ b/workers/commandor_page.py @@ -1,5 +1,6 @@ import logging import random +import re import string import threading import time @@ -17,6 +18,7 @@ RDV_URL = "https://rendezvousparis.hermes.com/client/register" # RDV_URL = "file:///Users/lpan/Downloads/test_appointment.html" # RDV_URL = "https://api.ipify.org" # RDV_URL ="https://bot.sannysoft.com/" +REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+" otp_value = None OTP_FIELD_ID = "#sms_code" MESSAGE_FIELD_CLASS = ".message" @@ -26,7 +28,7 @@ DOUBLE_REQUEST_ERROR_MESSAGE = "A request with the same data has already been va TOO_MANY_REQUEST_ERROR_MESSAGE = "Due to a large number of requests" TIME_OUT = 400000 OTP_TIMEOUT = 240 -PAGE_TIMEOUT = 20000 +PAGE_TIMEOUT = 30000 def get_random_wait_time() -> float: @@ -138,6 +140,7 @@ class CommandorPage: } """) self.page.on("load", self._on_page_loaded) + self.page.on("response", self.handle_response) self.page.goto(RDV_URL, timeout=PAGE_TIMEOUT) return self.page.content() except Exception as error: @@ -147,6 +150,12 @@ class CommandorPage: self.browser.close() return None + def handle_response(self, response): + pattern = re.compile(REGEX_RDV_URL) + if pattern.match(response.url): + self.logger.info("result url found: " + response.url) + self.publish_message_to_queue(self.contact, PublishType.PENDING, response.url) + def start_page(self, proxy): e = threading.Event() self._run(e, proxy)