add button to GUI

This commit is contained in:
Lei PAN
2022-05-27 12:38:36 +02:00
parent c50787e4bf
commit 1b446965aa
4 changed files with 39 additions and 13 deletions
+9 -8
View File
@@ -10,6 +10,7 @@ from playwright.sync_api import sync_playwright
import params
from params import PROXY_SERVER, PROXY_PASSWORD
from pojo.ModeEnum import ModeEnum
from pojo.ReserveResultPojo import ReserveResultPojo, PublishType
from pojo.contact_pojo import ContactPojo
from workers.SolveCaptch import SolveCaptcha
@@ -46,7 +47,7 @@ class Tls(threading.local):
class CommandorPage:
tls = Tls()
def __init__(self, contact: ContactPojo, store_type=0, proxy_type=0):
def __init__(self, contact: ContactPojo, store_type=0, proxy_type=0, mode: ModeEnum = ModeEnum.MANUAL):
self.otp_value = None
self.logger = logging.getLogger("CommandorPage:" + str(contact.phone))
self.is_finished = False
@@ -55,6 +56,7 @@ class CommandorPage:
self.is_event_sent = False
self.is_captcha_in_error = False
self.is_filling_fields = False
self.appointment_mode = mode
# 0: random
# 1: faubourg
# 2: George
@@ -130,7 +132,8 @@ class CommandorPage:
self._set_email(self.contact.mail)
self.setIdNumber(self.contact.passport)
self._checkCgu()
self.resolve_captcha()
if self.appointment_mode == ModeEnum.AUTOMATIC:
self.resolve_captcha()
self.is_filling_fields = False
def start_browser(self, proxy, pwright, device) -> Union[str, None]:
@@ -244,15 +247,13 @@ class CommandorPage:
if not self.is_finished:
params.oracle_log_sender.send_double_data_error(self.contact)
self.is_finished = True
time.sleep(1)
self.browser.close()
self.termine()
elif TOO_MANY_REQUEST_ERROR_MESSAGE in erro_content:
# this email has been already used
if not self.is_finished:
params.oracle_log_sender.send_too_many_error(self.contact)
self.is_finished = True
time.sleep(1)
self.browser.close()
self.termine()
elif CAPTCHA_ERROR_MESSAGE in erro_content:
# this email has been already used
self.is_captcha_in_error = True
@@ -260,8 +261,7 @@ class CommandorPage:
params.oracle_log_sender.send_captcha_error(self.contact)
self.is_finished = True
# no need to retry captcha, if retry ,will generate DOUBLE_REQUEST_ERROR_MESSAGE
time.sleep(1)
self.browser.close()
self.termine()
# self.resolve_captcha()
def _set_email(self, email):
@@ -314,6 +314,7 @@ class CommandorPage:
def termine(self):
self.logger.info("will close browser")
time.sleep(1)
self.browser.close()
def publish_message_to_queue(self, contact: ContactPojo, status: PublishType, url: str):