check sms time before extracting otp
This commit is contained in:
@@ -10,7 +10,7 @@ from gsmmodem import GsmModem
|
||||
from ModemPool import ModemPool
|
||||
from card_pool import CardPool
|
||||
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 pojo.ReserveResultPojo import ReserveResultPojo
|
||||
from utils.excel_reader import ExcelHelper
|
||||
@@ -107,22 +107,27 @@ def handle_sms(sms):
|
||||
logger.info(
|
||||
u'== SMS message received ==\nFrom: {0}\nTime: {1}\nMessage:\n{2}\n'.format(sms.number, sms.time, sms.text))
|
||||
# extract the otp number
|
||||
logger.info("try to extract the otp")
|
||||
pattern = r'\d{6,8}'
|
||||
# if re.match(pattern, sms.text):
|
||||
match = re.search(pattern, sms.text)
|
||||
otp = match.group(0)
|
||||
logger.info("otp is " + otp)
|
||||
commandor.send_otp(otp)
|
||||
# wait for the sms for 20 seconds
|
||||
global is_finished
|
||||
while not is_finished:
|
||||
time.sleep(2)
|
||||
is_finished = True
|
||||
global current_gsm_modem
|
||||
if current_gsm_modem:
|
||||
logger.info("will close used modem")
|
||||
current_gsm_modem.close()
|
||||
date = str(sms.time)[0:10]
|
||||
if date == str(datetime.date.today()):
|
||||
logger.info("this sms is for today")
|
||||
logger.info("try to extract the otp")
|
||||
pattern = r'\d{6,8}'
|
||||
# if re.match(pattern, sms.text):
|
||||
match = re.search(pattern, sms.text)
|
||||
otp = match.group(0)
|
||||
logger.info("otp is " + otp)
|
||||
commandor.send_otp(otp)
|
||||
# wait for the sms for 20 seconds
|
||||
global is_finished
|
||||
while not is_finished:
|
||||
time.sleep(2)
|
||||
is_finished = True
|
||||
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:
|
||||
@@ -156,7 +161,7 @@ def read_all_the_phone_number():
|
||||
slot_number = 1
|
||||
slot_sum = 31
|
||||
# card_pool.switch_to_slot(3)
|
||||
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user