optimization when error
This commit is contained in:
+1
-2
@@ -8,7 +8,7 @@ a = Analysis(
|
|||||||
['appointment.py'],
|
['appointment.py'],
|
||||||
pathex=[],
|
pathex=[],
|
||||||
binaries=[],
|
binaries=[],
|
||||||
datas=[],
|
datas=[('appointment.json','.')],
|
||||||
hiddenimports=[],
|
hiddenimports=[],
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
hooksconfig={},
|
hooksconfig={},
|
||||||
@@ -49,7 +49,6 @@ coll = COLLECT(
|
|||||||
name='appointment',
|
name='appointment',
|
||||||
)
|
)
|
||||||
import shutil
|
import shutil
|
||||||
shutil.copyfile('./appointment.json', '{0}/appointment.json'.format(DISTPATH))
|
|
||||||
shutil.copyfile('./contact_all.xlsx', '{0}/contact_all.xlsx'.format(DISTPATH))
|
shutil.copyfile('./contact_all.xlsx', '{0}/contact_all.xlsx'.format(DISTPATH))
|
||||||
shutil.copyfile('./config.ini', '{0}/config.ini'.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))
|
#shutil.copytree('./venv/Lib/site-packages/grpc/_cython/_credentials', '{0}/appointment/grpc/_cython/_credentials'.format(DISTPATH))
|
||||||
@@ -8,7 +8,7 @@ a = Analysis(
|
|||||||
['appointment.py'],
|
['appointment.py'],
|
||||||
pathex=[],
|
pathex=[],
|
||||||
binaries=[],
|
binaries=[],
|
||||||
datas=[],
|
datas=[('appointment.json','.')],
|
||||||
hiddenimports=[],
|
hiddenimports=[],
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
hooksconfig={},
|
hooksconfig={},
|
||||||
@@ -49,7 +49,6 @@ coll = COLLECT(
|
|||||||
name='appointment',
|
name='appointment',
|
||||||
)
|
)
|
||||||
import shutil
|
import shutil
|
||||||
shutil.copyfile('./appointment.json', '{0}/appointment.json'.format(DISTPATH))
|
|
||||||
shutil.copyfile('./contact_all.xlsx', '{0}/contact_all.xlsx'.format(DISTPATH))
|
shutil.copyfile('./contact_all.xlsx', '{0}/contact_all.xlsx'.format(DISTPATH))
|
||||||
shutil.copyfile('./config.ini', '{0}/config.ini'.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))
|
shutil.copytree('./venv/lib/python3.8/site-packages/grpc/_cython/_credentials', '{0}/appointment/grpc/_cython/_credentials'.format(DISTPATH))
|
||||||
+7
-2
@@ -1,13 +1,18 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
import getpass
|
import getpass
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
home = str(Path.home())
|
||||||
config = configparser.ConfigParser()
|
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']
|
CONTACT_LIST_FILE = config['DEFAULT']['contact_list_file']
|
||||||
FIREBASE_CONFIG_FILE = config['DEFAULT']['firebase_config_file']
|
FIREBASE_CONFIG_FILE = config['DEFAULT']['firebase_config_file']
|
||||||
LOGS_DIR = config['DEFAULT']['LOGS_DIR']
|
LOGS_DIR = config['DEFAULT']['LOGS_DIR']
|
||||||
username = getpass.getuser()
|
username = getpass.getuser()
|
||||||
LOG_SOURCE = username
|
LOG_SOURCE = "Macbookpro13"
|
||||||
|
|
||||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import definitions
|
|||||||
class PublishType(Enum):
|
class PublishType(Enum):
|
||||||
SUCCESS = "SUCCESS"
|
SUCCESS = "SUCCESS"
|
||||||
ERROR = "ERROR"
|
ERROR = "ERROR"
|
||||||
|
PENDING = "PENDING"
|
||||||
|
|
||||||
|
|
||||||
@dataclass_json
|
@dataclass_json
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
|
import re
|
||||||
import string
|
import string
|
||||||
import threading
|
import threading
|
||||||
import time
|
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 = "file:///Users/lpan/Downloads/test_appointment.html"
|
||||||
# RDV_URL = "https://api.ipify.org"
|
# RDV_URL = "https://api.ipify.org"
|
||||||
# RDV_URL ="https://bot.sannysoft.com/"
|
# RDV_URL ="https://bot.sannysoft.com/"
|
||||||
|
REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
||||||
otp_value = None
|
otp_value = None
|
||||||
OTP_FIELD_ID = "#sms_code"
|
OTP_FIELD_ID = "#sms_code"
|
||||||
MESSAGE_FIELD_CLASS = ".message"
|
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"
|
TOO_MANY_REQUEST_ERROR_MESSAGE = "Due to a large number of requests"
|
||||||
TIME_OUT = 400000
|
TIME_OUT = 400000
|
||||||
OTP_TIMEOUT = 240
|
OTP_TIMEOUT = 240
|
||||||
PAGE_TIMEOUT = 20000
|
PAGE_TIMEOUT = 30000
|
||||||
|
|
||||||
|
|
||||||
def get_random_wait_time() -> float:
|
def get_random_wait_time() -> float:
|
||||||
@@ -138,6 +140,7 @@ class CommandorPage:
|
|||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
self.page.on("load", self._on_page_loaded)
|
self.page.on("load", self._on_page_loaded)
|
||||||
|
self.page.on("response", self.handle_response)
|
||||||
self.page.goto(RDV_URL, timeout=PAGE_TIMEOUT)
|
self.page.goto(RDV_URL, timeout=PAGE_TIMEOUT)
|
||||||
return self.page.content()
|
return self.page.content()
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
@@ -147,6 +150,12 @@ class CommandorPage:
|
|||||||
self.browser.close()
|
self.browser.close()
|
||||||
return None
|
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):
|
def start_page(self, proxy):
|
||||||
e = threading.Event()
|
e = threading.Event()
|
||||||
self._run(e, proxy)
|
self._run(e, proxy)
|
||||||
|
|||||||
Reference in New Issue
Block a user