will merge gsm in project
This commit is contained in:
+21
-10
@@ -28,6 +28,7 @@ CONFIRMED_MESSAGE = "Your request for a Leather Goods appointment has been regis
|
|||||||
class CommandorPage:
|
class CommandorPage:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.otp_value = None
|
self.otp_value = None
|
||||||
|
self.logger = logging.getLogger("CommandorPage")
|
||||||
|
|
||||||
def _run(self, e: threading.Event, proxy, contact: ContactPojo, on_ready_for_otp, on_success):
|
def _run(self, e: threading.Event, proxy, contact: ContactPojo, on_ready_for_otp, on_success):
|
||||||
self.contact = contact
|
self.contact = contact
|
||||||
@@ -41,14 +42,7 @@ class CommandorPage:
|
|||||||
# elif "firefox" in user_agent.lower():
|
# elif "firefox" in user_agent.lower():
|
||||||
# self.browser = pwright.firefox.launch(headless=False, timeout=90000, proxy=proxy)
|
# self.browser = pwright.firefox.launch(headless=False, timeout=90000, proxy=proxy)
|
||||||
# else:
|
# else:
|
||||||
self.browser = pwright.firefox.launch(headless=False, timeout=90000, proxy=proxy)
|
self.start_brower(proxy, pwright, user_agent)
|
||||||
print("user_agent is " + user_agent)
|
|
||||||
self.page = self.browser.new_page(
|
|
||||||
user_agent=user_agent)
|
|
||||||
# hide webdriver information
|
|
||||||
self.page.add_init_script("""() => Object.defineProperty(navigator,'webdriver',{get: () => undefined}""")
|
|
||||||
self.page.on("load", self._on_page_loaded)
|
|
||||||
self.page.goto(RDV_URL, timeout=90000)
|
|
||||||
self._setPhoneCountry()
|
self._setPhoneCountry()
|
||||||
self._setPhoneNumber(contact.phone)
|
self._setPhoneNumber(contact.phone)
|
||||||
self._setName(contact.last_name, contact.first_name)
|
self._setName(contact.last_name, contact.first_name)
|
||||||
@@ -63,19 +57,36 @@ class CommandorPage:
|
|||||||
on_ready_for_otp(e, self)
|
on_ready_for_otp(e, self)
|
||||||
event_is_set = e.wait()
|
event_is_set = e.wait()
|
||||||
logging.info('event set: %s', event_is_set)
|
logging.info('event set: %s', event_is_set)
|
||||||
self.fill_otp(self.otp_value)
|
if self.otp_value:
|
||||||
|
self.fill_otp(self.otp_value)
|
||||||
self.clickOnValidBtn()
|
self.clickOnValidBtn()
|
||||||
otp_sent = self.page.locator(MESSAGE_FIELD_CLASS)
|
otp_sent = self.page.locator(MESSAGE_FIELD_CLASS)
|
||||||
otp_sent.wait_for(state='visible')
|
otp_sent.wait_for(state='visible')
|
||||||
message = self.page.content()
|
message = self.page.content()
|
||||||
print("message is:" + message)
|
print("message is:" + message)
|
||||||
|
time.sleep(2)
|
||||||
if CONFIRMED_MESSAGE in message:
|
if CONFIRMED_MESSAGE in message:
|
||||||
# publish the successful message
|
# publish the successful message
|
||||||
print("url is " + self.page.url)
|
print("url is " + self.page.url)
|
||||||
self.publish_message_to_queue(contact, message, self.page.url)
|
self.publish_message_to_queue(contact, message, self.page.url)
|
||||||
time.sleep(2)
|
else:
|
||||||
|
print("timeout")
|
||||||
|
self.reset_air_plan_mode()
|
||||||
# check and send successful event
|
# check and send successful event
|
||||||
|
|
||||||
|
def start_brower(self, proxy, pwright, user_agent):
|
||||||
|
try:
|
||||||
|
self.browser = pwright.firefox.launch(headless=False, timeout=90000, proxy=proxy)
|
||||||
|
print("user_agent is " + user_agent)
|
||||||
|
self.page = self.browser.new_page(
|
||||||
|
user_agent=user_agent)
|
||||||
|
# hide webdriver information
|
||||||
|
self.page.add_init_script("""() => Object.defineProperty(navigator,'webdriver',{get: () => undefined}""")
|
||||||
|
self.page.on("load", self._on_page_loaded)
|
||||||
|
self.page.goto(RDV_URL, timeout=90000)
|
||||||
|
except Exception as error:
|
||||||
|
self.logger.exception(error)
|
||||||
|
|
||||||
def start_page(self, proxy, contact: ContactPojo, on_ready_for_otp, on_sucess) -> threading.Event:
|
def start_page(self, proxy, contact: ContactPojo, on_ready_for_otp, on_sucess) -> threading.Event:
|
||||||
e = threading.Event()
|
e = threading.Event()
|
||||||
t = threading.Thread(target=self._run, args=(e, proxy, contact, on_ready_for_otp, on_sucess))
|
t = threading.Thread(target=self._run, args=(e, proxy, contact, on_ready_for_otp, on_sucess))
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ def timeout_occurred(serial_modem: SerialModem):
|
|||||||
firebase_store_manager.save_timeout_contact(serial_modem.contact)
|
firebase_store_manager.save_timeout_contact(serial_modem.contact)
|
||||||
oracle_log_sender.send_timeout_log(serial_modem)
|
oracle_log_sender.send_timeout_log(serial_modem)
|
||||||
logger.info("will close timeout modem")
|
logger.info("will close timeout modem")
|
||||||
|
global thread_event
|
||||||
|
thread_event.set()
|
||||||
serial_modem.modem.close()
|
serial_modem.modem.close()
|
||||||
commandor.reset_air_plan_mode()
|
commandor.reset_air_plan_mode()
|
||||||
|
|
||||||
@@ -176,8 +178,8 @@ def on_ready_for_otp(e: Event, commandor: CommandorPage):
|
|||||||
|
|
||||||
|
|
||||||
def start_book():
|
def start_book():
|
||||||
slot_number = 1
|
slot_number = 2
|
||||||
slot_sum = 1
|
slot_sum = 2
|
||||||
for i in range(slot_number, slot_sum + 1):
|
for i in range(slot_number, slot_sum + 1):
|
||||||
card_pool.reset()
|
card_pool.reset()
|
||||||
logger.info("will switch to " + str(i))
|
logger.info("will switch to " + str(i))
|
||||||
@@ -191,14 +193,13 @@ def start_book():
|
|||||||
excel_reader = ExcelHelper()
|
excel_reader = ExcelHelper()
|
||||||
contacts = excel_reader.read_contacts()
|
contacts = excel_reader.read_contacts()
|
||||||
global current_sim_position
|
global current_sim_position
|
||||||
current_sim_position = 1
|
current_sim_position = 0
|
||||||
for modem in modem_list:
|
for modem in modem_list:
|
||||||
current_sim_position = current_sim_position + 1
|
current_sim_position = current_sim_position + 1
|
||||||
try:
|
try:
|
||||||
# get contact for current modem
|
|
||||||
modem.get_ccid()
|
modem.get_ccid()
|
||||||
# find the contact with ccid
|
# find the contact with ccid
|
||||||
contact = [contact for contact in contacts if contact.ccid.replace("F", "") == modem.ccid]
|
contact = [contact for contact in contacts if contact.ccid.replace("F", "") == modem.ccid.replace("F", "")]
|
||||||
if len(contact) > 0:
|
if len(contact) > 0:
|
||||||
modem.phone_number = contact[0].phone
|
modem.phone_number = contact[0].phone
|
||||||
modem.contact = contact[0]
|
modem.contact = contact[0]
|
||||||
|
|||||||
+2
-3
@@ -85,8 +85,8 @@ def init_modems() -> list:
|
|||||||
|
|
||||||
|
|
||||||
def start_book():
|
def start_book():
|
||||||
slot_number = 1
|
slot_number = 2
|
||||||
slot_sum = 27
|
slot_sum = 2
|
||||||
for i in range(slot_number, slot_sum + 1):
|
for i in range(slot_number, slot_sum + 1):
|
||||||
card_pool.reset()
|
card_pool.reset()
|
||||||
logger.info("will switch to " + str(i))
|
logger.info("will switch to " + str(i))
|
||||||
@@ -94,7 +94,6 @@ def start_book():
|
|||||||
modem_pool = ModemPool(get_devices_ports())
|
modem_pool = ModemPool(get_devices_ports())
|
||||||
modem_pool.reset_all_modems()
|
modem_pool.reset_all_modems()
|
||||||
modem_list = init_modems()
|
modem_list = init_modems()
|
||||||
# create listeners for chaque modem
|
|
||||||
# read the contact, and merge the 2 objects together
|
# read the contact, and merge the 2 objects together
|
||||||
excel_reader = ExcelHelper()
|
excel_reader = ExcelHelper()
|
||||||
contacts = excel_reader.read_contacts()
|
contacts = excel_reader.read_contacts()
|
||||||
|
|||||||
Reference in New Issue
Block a user