Merge branch 'master' into feature/gsm_modem_in_project

This commit is contained in:
2022-03-17 11:13:17 +01:00
9 changed files with 76 additions and 15 deletions
-1
View File
@@ -3,7 +3,6 @@ from enum import Enum
from playwright.sync_api import sync_playwright
import params
from db.DbManager import DataManager
from logs.LogSender import TYPE_EVENT_CHECK_RESULTS, LOG_SUBJECT_EVENT
from pojo.ReserveResultPojo import ReserveResultPojo
BIN
View File
Binary file not shown.
+4 -1
View File
@@ -39,7 +39,10 @@ class DataManager:
return sim_info_collection
def get_all_successful_items(self):
doc_ref = self._db.collection(str(datetime.date.today()))
return self.get_all_successful_items_for_day(str(datetime.date.today()))
def get_all_successful_items_for_day(self, day):
doc_ref = self._db.collection(day)
return doc_ref
def save_sim_info(self, simInfoPojo: SimInfoPojo):
+57
View File
@@ -0,0 +1,57 @@
import xlsxwriter
import params
from pojo.ReserveResultPojo import ReserveResultPojo
from pojo.contact_pojo import ContactPojo
from utils.excel_reader import ExcelHelper
def write_the_valid_profiles_to_excel():
day_list = ['2022-03-04', '2022-03-07', '2022-03-08', '2022-03-09', '2022-03-10', '2022-03-11', '2022-03-14',
'2022-03-15', '2022-03-16']
collection = []
for day in day_list:
collection.extend(params.firebase_store_manager.get_all_successful_items_for_day(day).stream())
valid_contacts = []
exist_contacts = ExcelHelper().read_contacts()
for valid_appointment in collection:
reserve_pojo = ReserveResultPojo.from_firestore_dict(valid_appointment.to_dict())
# check whether the contact exists already
exist = [contact for contact in valid_contacts if contact.mail == reserve_pojo.email]
if len(exist) == 0:
contact = ContactPojo(reserve_pojo.phone, passport_number=reserve_pojo.passport,
last_name=reserve_pojo.lastName, first_name=reserve_pojo.firstName, ccid="",
mail=reserve_pojo.email, position=0)
if contact.passport == None or len(contact.passport) == 0:
old_contact = [item for item in exist_contacts if item.mail == contact.mail]
if len(old_contact) > 0:
contact.passport = old_contact[0].passport
print(contact)
valid_contacts.append(contact)
row = 0
col = 0
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('valid_profile.xlsx')
header_data = ['name', 'phone', 'passport', 'email', 'ccid', 'position']
worksheet = workbook.add_worksheet()
header_format = workbook.add_format({'bold': True})
for col_num, data in enumerate(header_data):
worksheet.write(row, col_num, data, header_format)
row = row + 1
for info in valid_contacts:
# Iterate over the data and write it out row by row.
worksheet.write(row, col, "{} {}".format(info.last_name, info.first_name))
worksheet.write(row, col + 1, info.phone)
worksheet.write(row, col + 2, info.passport)
worksheet.write(row, col + 3, info.mail)
worksheet.write(row, col + 4, info.ccid)
row += 1
workbook.close()
if __name__ == '__main__':
write_the_valid_profiles_to_excel()
+12 -8
View File
@@ -8,8 +8,8 @@ from typing import Union
from gsmmodem import GsmModem
import params
from ModemPool import ModemPool
from card_pool import CardPool
from modems.ModemPool import ModemPool
from modems.card_pool import CardPool
from commandor import Commandor
from logs.LogSender import LOG_APPOINTMENT_TIMEOUT, LOG_SUBJECT_EVENT, TYPE_EVENT_RESET_ALL_SIM_CARDS
from params import MODEM_POOL_PORTS, CARD_POOL_PORT, firebase_store_manager, oracle_log_sender
@@ -72,7 +72,7 @@ def start_to_handle_sms(serial_modem: SerialModem):
serial_modem.modem.smsReceivedCallback = handle_sms
global is_finished
is_finished = False
serial_modem.modem.smsTextMode = True
serial_modem.modem.smsTextMode = False
logger.info('Waiting for SMS message, for phone number ' + str(serial_modem.phone_number))
listen_at = time.time()
while not is_finished:
@@ -113,9 +113,9 @@ def handle_sms(sms):
logger.info("will close used modem")
current_gsm_modem.close()
else:
logger.info("the sms is not for RDV")
logger.info("The sms is not for RDV")
else:
logger.info("the sms is not for today")
logger.info("The sms is not for today")
def init_modems() -> list:
@@ -128,7 +128,7 @@ def init_modems() -> list:
def on_message_received(ch, method, properties, body):
logger.info(" [x] Received {} {}".format(body, datetime.datetime.now()))
print(" [x] Received {} {}".format(body, datetime.datetime.now()))
# parse the received message
result = ReserveResultPojo.from_json(body)
result.sim_position = current_sim_position
@@ -165,8 +165,8 @@ def read_all_the_phone_number():
def start_book():
slot_number = 14
slot_sum = 31
slot_number = 1
slot_sum = 12
for i in range(slot_number, slot_sum + 1):
card_pool.reset()
logger.info("will switch to " + str(i))
@@ -197,6 +197,8 @@ def start_book():
continue
if modem.contact:
logger.info("contact found for this ccid")
signal = modem.modem.signalStrength
logger.info("signal for this sim: "+str(signal))
commandor.start_page(modem.contact)
start_to_handle_sms(modem)
except Exception as error:
@@ -210,3 +212,5 @@ if __name__ == '__main__':
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
start_listen()
start_book()
# card_pool.switch_to_slot(31)
+1 -3
View File
@@ -5,8 +5,6 @@ import serial
import params
from logs.LogSender import LOG_SUBJECT_EVENT, TYPE_EVENT_CHANGE_SLOT
PORT = "/dev/tty.usbmodem1432101"
BAUDRATE = 115200
@@ -45,7 +43,7 @@ class CardPool:
if __name__ == '__main__':
card_pool = CardPool(PORT)
card_pool = CardPool(params.CARD_POOL_PORT)
# print(card_pool.find_current_slot())
card_pool.reset()
# card_pool.switch_to_next()
+2 -2
View File
@@ -1,7 +1,7 @@
import logging
import params
from ModemPool import ModemPool
from modems.ModemPool import ModemPool
from logs.AppLogging import init_logger
from logs.LogSender import LOG_SUBJECT_EVENT, TYPE_EVENT_RESET_ALL_SIM_CARDS
from main import card_pool, get_devices_ports
@@ -10,7 +10,7 @@ from main import card_pool, get_devices_ports
def read_all_the_phone_number():
params.oracle_log_sender.send_log(msg="SIM卡自检开始", subject=LOG_SUBJECT_EVENT, type=TYPE_EVENT_RESET_ALL_SIM_CARDS)
slot_number = 1
slot_sum = 31
slot_sum = 12
# card_pool.switch_to_slot(29)
params.firebase_store_manager.clear_all_sim_info()
for i in range(slot_number, slot_sum + 1):
Binary file not shown.