From 6f58c95aaebd4c710d7551a0d82c74f430bd14e9 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Fri, 25 Mar 2022 14:16:06 +0100 Subject: [PATCH] add ccid to log --- main.py | 7 ++++--- pojo/serial_modem.py | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 8ace3fe..2e2e808 100644 --- a/main.py +++ b/main.py @@ -199,13 +199,14 @@ def start_book(): try: modem.get_ccid() # find the contact with ccid - contact = [contact for contact in contacts if contact.ccid.replace("F", "") == modem.ccid.replace("F", "")] + contact = [contact for contact in contacts if + contact.ccid.replace("F", "") == modem.ccid.replace("F", "")] if len(contact) > 0: modem.phone_number = contact[0].phone modem.contact = contact[0] else: - logger.info("contact not found for this ccid") - error_msg = "slot({}),sim({})".format(i, current_sim_position) + logger.info("contact not found for this ccid:{}".format(modem.ccid)) + error_msg = "slot({}):sim({}):ccid({})".format(i, current_sim_position, modem.ccid) oracle_log_sender.send_contact_not_found(error_msg) modem.modem.close() continue diff --git a/pojo/serial_modem.py b/pojo/serial_modem.py index 81448df..f639638 100644 --- a/pojo/serial_modem.py +++ b/pojo/serial_modem.py @@ -1,3 +1,4 @@ +import logging from dataclasses import dataclass from gsmmodem import GsmModem @@ -13,14 +14,15 @@ class SerialModem(): def __init__(self, modem: GsmModem, ccid: str = None): self.modem = modem self.ccid = ccid + self.logger = logging.getLogger("SerialModem") def get_ccid(self): cmd = "AT+CCID" self.modem.connect("0000") - print("try to get ccid") + self.logger.info("try to get ccid") response = self.modem.write(cmd, True) self.ccid = response[0].split(" ")[1].replace("\"", "") - print("The SIM card ccid is:" + self.ccid) + self.logger.info("The SIM card ccid is:" + self.ccid) # print("try to get phone number") # cmd_phone_number = "AT+CPBS=ON" # openBook = self.modem.write(cmd_phone_number, True)