diff --git a/definitions.py b/definitions.py index 1267de0..291b8bd 100644 --- a/definitions.py +++ b/definitions.py @@ -1,3 +1,5 @@ import os +BAUDRATE = 115200 + ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/main.py b/main.py index a547776..5edd2b8 100644 --- a/main.py +++ b/main.py @@ -19,13 +19,15 @@ from pojo.serial_modem import SerialModem from logs.AppLogging import init_logger from utils.message_receiver import MessageReceiver -BAUDRATE = 115200 OTP_TIMEOUT = 90 is_finished = False commandor = Commandor() contacts = [] current_gsm_modem = None card_pool = CardPool(CARD_POOL_PORT) +# used to save the current slot position +current_card_pool_slot = 1 +current_sim_position = 1 def get_devices_ports() -> list: @@ -60,10 +62,6 @@ def get_phone_number(ser): send_command(cmd, ser) -def execut_USSD_cmd(cmd, ser): - send_command(cmd, ser) - - def create_modem_for_port(port: str) -> Union[SerialModem, None]: logger.info('Initializing modem... for ' + port) # Uncomment the following line to see what the modem is doing: @@ -145,7 +143,9 @@ def on_message_received(ch, method, properties, body): logger.info(" [x] Received {} {}".format(body, datetime.datetime.now())) # parse the received message result = ReserveResultPojo.from_json(body) - print(result) + result.sim_position = current_sim_position + result.slot_position = current_card_pool_slot + logger.info(result) firebase_store_manager.save(result) oracle_log_sender.send_appoint_result(result) # set the flag to True @@ -162,12 +162,14 @@ def start_listen(): def read_all_the_phone_number(): params.oracle_log_sender.send_log(msg="SIM卡自检开始", subject=LOG_SUBJECT_EVENT, type=LOG_SUBJECT_EVENT) slot_number = 1 + global current_card_pool_slot slot_sum = 30 # card_pool.switch_to_slot(29) firebase_store_manager.clear_all_sim_info() for i in range(slot_number, slot_sum + 1): card_pool.reset() - print("will switch to " + str(i)) + logger.info("will switch to " + str(i)) + current_card_pool_slot = i card_pool.switch_to_slot(i) modem_pool = ModemPool(get_devices_ports()) modem_pool.reset_all_modems() @@ -179,7 +181,7 @@ def start_book(): slot_sum = 30 for i in range(slot_number, slot_sum + 1): card_pool.reset() - print("will switch to " + str(i)) + logger.info("will switch to " + str(i)) card_pool.switch_to_slot(i) modem_pool = ModemPool(get_devices_ports()) modem_pool.reset_all_modems() @@ -189,7 +191,10 @@ def start_book(): excel_reader = ExcelHelper() global contacts contacts = excel_reader.read_contacts() + global current_sim_position + current_sim_position = 1 for modem in modem_list: + current_sim_position = current_sim_position + 1 try: # get contact for current modem modem.get_ccid() diff --git a/notification/mailer.py b/notification/mailer.py index 1229b9e..a96dfd0 100644 --- a/notification/mailer.py +++ b/notification/mailer.py @@ -57,7 +57,8 @@ class Mailer: if __name__ == '__main__': result = ReserveResultPojo(email="panleicim@gmail.com", phone="0649614591", url="url", firstName="Lei", - lastName="PAN", message="msg", type=PublishType.SUCCESS) + lastName="PAN", message="msg", type=PublishType.SUCCESS, passport="Ed1543183", + slot_position=1, sim_position=1) mytemplate = Template(filename=definitions.ROOT_DIR + "/templates/appointment_results.html") print(mytemplate.render(result_list=[result])) diff --git a/pojo/ReserveResultPojo.py b/pojo/ReserveResultPojo.py index 46f4668..88167f4 100644 --- a/pojo/ReserveResultPojo.py +++ b/pojo/ReserveResultPojo.py @@ -20,6 +20,9 @@ class ReserveResultPojo: email: None id = None accepted = None + passport: str + slot_position: int + sim_position: int @staticmethod def from_firestore_dict(source): @@ -37,6 +40,15 @@ class ReserveResultPojo: if 'accepted' in source: accepted = source['accepted'] result.accepted = accepted + if 'sim_position' in source: + sim_position = source['sim_position'] + result.sim_position = sim_position + if 'slot_position' in source: + slot_position = source['slot_position'] + result.slot_position = slot_position + if 'passport' in source: + passport = source['passport'] + result.passport = passport result.id = id return result @@ -49,7 +61,10 @@ class ReserveResultPojo: u'firstName': self.firstName, u'lastName': self.lastName, u'email': self.email, - u'url': self.url + u'passport': self.passport, + u'url': self.url, + u'sim_position': self.sim_position, + u'slot_position': self.slot_position } return dest diff --git a/templates/appointment_results.html b/templates/appointment_results.html index 45e603e..1e0ef80 100644 --- a/templates/appointment_results.html +++ b/templates/appointment_results.html @@ -1,7 +1,9 @@