check sms time before extracting otp
This commit is contained in:
@@ -35,8 +35,6 @@ class ModemPool:
|
|||||||
self._send_command("AT+CFUN=1,1\r", ser)
|
self._send_command("AT+CFUN=1,1\r", ser)
|
||||||
# wait for 20 second, so that the modem can init all the sims
|
# wait for 20 second, so that the modem can init all the sims
|
||||||
time.sleep(20)
|
time.sleep(20)
|
||||||
for ser in self._serial_list:
|
|
||||||
ser.close()
|
|
||||||
|
|
||||||
def _generate_error_msg(self, slot_position, index, error: SIMError):
|
def _generate_error_msg(self, slot_position, index, error: SIMError):
|
||||||
msg = "slot({}) SIM({}), error:{}".format(slot_position, index + 1,
|
msg = "slot({}) SIM({}), error:{}".format(slot_position, index + 1,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from gsmmodem import GsmModem
|
|||||||
from ModemPool import ModemPool
|
from ModemPool import ModemPool
|
||||||
from card_pool import CardPool
|
from card_pool import CardPool
|
||||||
from commandor import Commandor
|
from commandor import Commandor
|
||||||
from logs.LogSender import LOG_APPOINTMENT_TIMEOUT, LOG_APPOINTMENT_SUCCESS
|
from logs.LogSender import LOG_APPOINTMENT_TIMEOUT
|
||||||
from params import MODEM_POOL_PORTS, CARD_POOL_PORT, firebase_store_manager, oracle_log_sender
|
from params import MODEM_POOL_PORTS, CARD_POOL_PORT, firebase_store_manager, oracle_log_sender
|
||||||
from pojo.ReserveResultPojo import ReserveResultPojo
|
from pojo.ReserveResultPojo import ReserveResultPojo
|
||||||
from utils.excel_reader import ExcelHelper
|
from utils.excel_reader import ExcelHelper
|
||||||
@@ -107,22 +107,27 @@ def handle_sms(sms):
|
|||||||
logger.info(
|
logger.info(
|
||||||
u'== SMS message received ==\nFrom: {0}\nTime: {1}\nMessage:\n{2}\n'.format(sms.number, sms.time, sms.text))
|
u'== SMS message received ==\nFrom: {0}\nTime: {1}\nMessage:\n{2}\n'.format(sms.number, sms.time, sms.text))
|
||||||
# extract the otp number
|
# extract the otp number
|
||||||
logger.info("try to extract the otp")
|
date = str(sms.time)[0:10]
|
||||||
pattern = r'\d{6,8}'
|
if date == str(datetime.date.today()):
|
||||||
# if re.match(pattern, sms.text):
|
logger.info("this sms is for today")
|
||||||
match = re.search(pattern, sms.text)
|
logger.info("try to extract the otp")
|
||||||
otp = match.group(0)
|
pattern = r'\d{6,8}'
|
||||||
logger.info("otp is " + otp)
|
# if re.match(pattern, sms.text):
|
||||||
commandor.send_otp(otp)
|
match = re.search(pattern, sms.text)
|
||||||
# wait for the sms for 20 seconds
|
otp = match.group(0)
|
||||||
global is_finished
|
logger.info("otp is " + otp)
|
||||||
while not is_finished:
|
commandor.send_otp(otp)
|
||||||
time.sleep(2)
|
# wait for the sms for 20 seconds
|
||||||
is_finished = True
|
global is_finished
|
||||||
global current_gsm_modem
|
while not is_finished:
|
||||||
if current_gsm_modem:
|
time.sleep(2)
|
||||||
logger.info("will close used modem")
|
is_finished = True
|
||||||
current_gsm_modem.close()
|
global current_gsm_modem
|
||||||
|
if current_gsm_modem:
|
||||||
|
logger.info("will close used modem")
|
||||||
|
current_gsm_modem.close()
|
||||||
|
else:
|
||||||
|
logger.info("the sms is not for today")
|
||||||
|
|
||||||
|
|
||||||
def init_modems() -> list:
|
def init_modems() -> list:
|
||||||
@@ -156,7 +161,7 @@ def read_all_the_phone_number():
|
|||||||
slot_number = 1
|
slot_number = 1
|
||||||
slot_sum = 31
|
slot_sum = 31
|
||||||
# card_pool.switch_to_slot(3)
|
# card_pool.switch_to_slot(3)
|
||||||
|
firebase_store_manager.clear_all_sim_info()
|
||||||
for i in range(slot_number, slot_sum + 1):
|
for i in range(slot_number, slot_sum + 1):
|
||||||
card_pool.reset()
|
card_pool.reset()
|
||||||
print("will switch to " + str(i))
|
print("will switch to " + str(i))
|
||||||
|
|||||||
Reference in New Issue
Block a user