add check sms and sen email if appointment is accepted

This commit is contained in:
2022-04-20 12:56:06 +02:00
parent d848ec9194
commit 71c1ff5fea
16 changed files with 130 additions and 31 deletions
+8 -9
View File
@@ -1,3 +1,4 @@
import logging
import re
import time
@@ -23,13 +24,14 @@ class ModemPool:
self.contacts = self._excel_helper.read_contacts("/contact_all.xlsx")
self._log_sender = oracle_log_sender
self._db_manager = firebase_store_manager
self.logger = logging.getLogger(self.TAG)
for port in self._port_list:
ser = serial.Serial(port, BAUDRATE, timeout=1)
self._serial_list.append(ser)
def reset_all_modems(self):
print("will reset modem pool")
self.logger.info("will reset modem pool")
for ser in self._serial_list:
# may encontre exception here, multi-access to serial port
time.sleep(2)
@@ -68,19 +70,19 @@ class ModemPool:
error_msg = "slot({}),sim({})".format(slot_position, sim_position)
oracle_log_sender.send_contact_not_found(error_msg)
else:
print("will get phone number for slot({}) SIM({}), port:{}".format(slot_position, index + 1, ser.port))
self.logger.info("will get phone number for slot({}) SIM({}), port:{}".format(slot_position, index + 1, ser.port))
if not self._select_sim_storage(ser):
print(self._generate_error_msg(slot_position, index, SIMError.STORAGE_ERROR))
self.logger.info(self._generate_error_msg(slot_position, index, SIMError.STORAGE_ERROR))
continue
msg = self._execut_USSD_cmd("AT+CUSD=1, *132#\r", ser)
if "Unfortunately" in str(msg):
print(self._generate_error_msg(slot_position, index, SIMError.SIM_DISABLED))
self.logger.info(self._generate_error_msg(slot_position, index, SIMError.SIM_DISABLED))
continue
elif "CME ERROR" in str(msg):
print(self._generate_error_msg(slot_position, index, SIMError.CME_ERROR))
self.logger.info(self._generate_error_msg(slot_position, index, SIMError.CME_ERROR))
continue
elif len(msg) == 0:
print(self._generate_error_msg(slot_position, index, SIMError.TIMEOUT))
self.logger.info(self._generate_error_msg(slot_position, index, SIMError.TIMEOUT))
continue
# find phone number
match = re.search(r'33\d{9}', str(msg))
@@ -93,9 +95,6 @@ class ModemPool:
sim_position=sim_position, operator=operator.value))
self._log_sender.send_log(phone_number, source=self.TAG, subject=SUBJECT_SIM_INFO,
type=LOG_APPOINTMENT_SUCCESS)
# write the number to sim card's phonebook
# cmd = f'AT+CPBW={self.phone_number_position},\"{phone_number}\"\r'
# self._send_command(cmd, ser, wait_time_in_s=2)
def _select_sim_storage(self, ser) -> bool:
# use SIM Card storage