Merge branch 'master' of bitbucket.org:panleicim/appointement_modem_pool
This commit is contained in:
@@ -7,3 +7,7 @@ utils/*.log
|
||||
/docs/sim_infos.xlsx
|
||||
.env
|
||||
/docs/.~sim_infos.xlsx
|
||||
./venv
|
||||
out
|
||||
lib
|
||||
appointment_*.log
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -78,7 +78,7 @@ def start_book(start_slot_number, end_slot_number, store=0):
|
||||
contacts = excel_reader.read_contacts()
|
||||
global current_sim_position
|
||||
current_sim_position = 0
|
||||
with ThreadPoolExecutor(max_workers=5) as executor:
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
for modem in modem_list:
|
||||
current_sim_position = current_sim_position + 1
|
||||
try:
|
||||
@@ -122,6 +122,5 @@ def get_proxy(phone_number):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 修改起始行,结束行
|
||||
# 第三个参数store等于0的时候是随机,传入1的时候是总店
|
||||
start_book(32, 32, store=0)
|
||||
# 修改起始行,结束行, 第三个参数store等于0的时候是随机,传入1的时候是总店
|
||||
start_book(17, 17, store=0)
|
||||
+18
-8
@@ -33,11 +33,11 @@ class ModemPool:
|
||||
def reset_all_modems(self):
|
||||
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)
|
||||
self._send_command("AT+CFUN=1,1\r", ser)
|
||||
# wait for 10 second, so that the modem can init all the sims
|
||||
time.sleep(10)
|
||||
#等待4秒
|
||||
time.sleep(4)
|
||||
self._send_command("AT+CFUN=1,1\r", ser, 10)
|
||||
#等待15秒,加载新的SIM卡
|
||||
time.sleep(15)
|
||||
|
||||
def _generate_error_msg(self, slot_position, index, error: SIMError):
|
||||
msg = "slot({}) SIM({}), error:{}".format(slot_position, index + 1,
|
||||
@@ -105,13 +105,22 @@ class ModemPool:
|
||||
else:
|
||||
return True
|
||||
|
||||
def check_response(self, msg:str) -> bool:
|
||||
print("msg is "+msg)
|
||||
# if 'NOT READY' in msg:
|
||||
# return False
|
||||
if 'OK' in msg:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def _send_command(self, cmd: str, ser, wait_time_in_s: int = 0) -> bytes:
|
||||
ser.write(cmd.encode())
|
||||
msg = None
|
||||
try:
|
||||
msg = ser.read(100)
|
||||
count = 0
|
||||
while 'OK' not in str(msg) and count < wait_time_in_s:
|
||||
while not self.check_response(str(msg)) and count < wait_time_in_s:
|
||||
time.sleep(1)
|
||||
count = count + 1
|
||||
msg = ser.read(100)
|
||||
@@ -125,5 +134,6 @@ class ModemPool:
|
||||
return self._send_command(cmd, ser, 120)
|
||||
|
||||
def close(self):
|
||||
for serial in self._serial_list:
|
||||
serial.close()
|
||||
pass
|
||||
# for serial in self._serial_list:
|
||||
# serial.close()
|
||||
|
||||
@@ -9,7 +9,7 @@ from pojo import ReserveResultPojo
|
||||
@dataclass
|
||||
class AcceptedResultPojo:
|
||||
|
||||
def __init__(self, msg: str, slot_position, sim_position, passport, email, name, phone):
|
||||
def __init__(self, msg: str, slot_position, sim_position, passport, email, name, phone, ccid: str, url):
|
||||
self.sms_msg = msg
|
||||
self.slot_position = slot_position
|
||||
self.sim_position = sim_position
|
||||
@@ -17,9 +17,19 @@ class AcceptedResultPojo:
|
||||
self.email = email
|
||||
self.name = name
|
||||
self.phone = phone
|
||||
self.ccid = ccid
|
||||
self.url = url
|
||||
|
||||
|
||||
def get_accepted_result_from(sms, sim_info: ReserveResultPojo) -> AcceptedResultPojo:
|
||||
return AcceptedResultPojo(sms.text, slot_position=sim_info.slot_position, sim_position=sim_info.sim_position,
|
||||
passport=sim_info.passport, email=sim_info.email, phone=sim_info.phone,
|
||||
name="{} {}".format(sim_info.lastName, sim_info.firstName))
|
||||
if sim_info is None:
|
||||
# send email even there are no reserve info
|
||||
return AcceptedResultPojo(sms.text, slot_position=0, sim_position=0,
|
||||
passport="", email="", phone="",
|
||||
name="", ccid="",
|
||||
url="")
|
||||
else:
|
||||
return AcceptedResultPojo(sms.text, slot_position=sim_info.slot_position, sim_position=sim_info.sim_position,
|
||||
passport=sim_info.passport, email=sim_info.email, phone=sim_info.phone,
|
||||
name="{} {}".format(sim_info.lastName, sim_info.firstName), ccid=sim_info.ccid,
|
||||
url=sim_info.url)
|
||||
|
||||
@@ -5,9 +5,7 @@ from mako.template import Template
|
||||
import boto3
|
||||
|
||||
import definitions
|
||||
import params
|
||||
from notification.AcceptedResultPojo import AcceptedResultPojo
|
||||
from pojo.ReserveResultPojo import ReserveResultPojo, PublishType
|
||||
|
||||
TEMPLATE_NAME = 'scrapy_template_email'
|
||||
AWS_CLIENT_NAME = "sesv2"
|
||||
@@ -53,14 +51,3 @@ class Mailer:
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
result = ReserveResultPojo(email="purge_jigsaws_0p@icloud.com", phone="0649614591", url="url", firstName="wenjing",
|
||||
lastName="Chen", 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]))
|
||||
mailer = Mailer()
|
||||
mailer.send_email([result])
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import os
|
||||
|
||||
from db.DbManager import DataManager
|
||||
from logs.LogSender import LogSender
|
||||
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
姓名:${result.name}
|
||||
<br/>
|
||||
<br/>电话: ${result.phone}
|
||||
<br/>
|
||||
<br/>邮件: ${result.email},
|
||||
<br/>
|
||||
<br/>护照: ${result.passport}
|
||||
<br/>
|
||||
<br/>SIM卡位置: 卡池第${result.slot_position}行,第${result.sim_position}列
|
||||
<br/> 短信: ${result.sms_msg}
|
||||
<br/>
|
||||
<br/> 短信内容: ${result.sms_msg}
|
||||
<br/>
|
||||
<br/> SIM卡CCID: ${result.ccid}
|
||||
<br/>
|
||||
<br/> 约会url: ${result.url}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import datetime
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
@@ -85,4 +84,4 @@ if __name__ == '__main__':
|
||||
worker = WaitSmsWorker(None)
|
||||
sms = Sms("HERMES RDV",
|
||||
"We are pleased to confirm your appointment. You will be welcomed on Apr 14, 2022 in our store at 17 rue de Sèvres at 4:45 PM. The given hour may be subje")
|
||||
worker.check_sms(sms, int('613467904'))
|
||||
worker.check_sms(sms, int('628973387'))
|
||||
|
||||
Reference in New Issue
Block a user