optimization when error

This commit is contained in:
PAN Lei
2022-05-20 13:46:47 +02:00
parent c056445268
commit 8444ea2c11
6 changed files with 20 additions and 7 deletions
View File
+1 -2
View File
@@ -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))
+1 -2
View File
@@ -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))
+7 -2
View File
@@ -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__))
+1
View File
@@ -10,6 +10,7 @@ import definitions
class PublishType(Enum):
SUCCESS = "SUCCESS"
ERROR = "ERROR"
PENDING = "PENDING"
@dataclass_json
+10 -1
View File
@@ -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)