need to remove duplicated emails

This commit is contained in:
2022-03-23 19:11:07 +01:00
parent 8432e33392
commit 2506165900
5 changed files with 22 additions and 32 deletions
BIN
View File
Binary file not shown.
+9 -6
View File
@@ -6,15 +6,15 @@ import xlsxwriter
import params
from pojo.ReserveResultPojo import ReserveResultPojo
from pojo.contact_pojo import ContactPojo
from utils.excel_reader import ExcelHelper
def get_random_id_number ()-> str:
def get_random_id_number() -> str:
# write_the_valid_profiles_to_excel()
S = 8 # number of characters in the string.
# call random.choices() string module to find the string in Uppercase + numeric data.
ran = ''.join(random.choices(string.digits, k = S))
id_number = "57"+str(ran)
print("The randomly generated string is : 94" + str(ran)) # print the random data
ran = ''.join(random.choices(string.digits, k=S))
id_number = "57" + str(ran)
print("The randomly generated string is : 94" + str(ran)) # print the random data
return id_number
@@ -36,6 +36,10 @@ def write_the_valid_profiles_to_excel():
contact = ContactPojo(reserve_pojo.phone, passport_number=get_random_id_number(),
last_name=reserve_pojo.lastName, first_name=reserve_pojo.firstName, ccid="",
mail=reserve_pojo.email, position=0)
seed = 8 # number of characters in the string.
# call random.choices() string module to find the string in Uppercase + numeric data.
ran = ''.join(random.choices(string.digits, k=seed))
contact.mail = "{}_{}{}@163.com".format(contact.first_name, contact.last_name, ran)
# contact.passport = get_random_id_number()
# if contact.passport == None or len(contact.passport) == 0:
# old_contact = [item for item in exist_contacts if item.mail == contact.mail]
@@ -67,7 +71,6 @@ def write_the_valid_profiles_to_excel():
workbook.close()
if __name__ == '__main__':
# get_random_id_number()
write_the_valid_profiles_to_excel()
+1 -1
View File
@@ -8,4 +8,4 @@ def init_logger():
filemode='a',
format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
datefmt='%D:%H:%M:%S',
level=logging.INFO)
level=logging.DEBUG)
+5 -6
View File
@@ -20,7 +20,7 @@ from pojo.serial_modem import SerialModem
from utils.excel_reader import ExcelHelper
from utils.message_receiver import MessageReceiver
OTP_TIMEOUT = 120
OTP_TIMEOUT = 180
is_finished = False
commandor = CommandorPage()
thread_event = None
@@ -69,7 +69,7 @@ def timeout_occurred(serial_modem: SerialModem):
def start_to_handle_sms(serial_modem: SerialModem):
global current_gsm_modem
current_gsm_modem = serial_modem.modem
current_gsm_modem.deleteMultipleStoredSms(memory="SM")
# current_gsm_modem.deleteMultipleStoredSms(memory="SM")
serial_modem.modem.smsReceivedCallback = handle_sms
global is_finished
is_finished = False
@@ -164,14 +164,13 @@ def on_ready_for_otp(e: Event, commandor: CommandorPage):
def start_book():
slot_number = 1
slot_sum = 2
for i in reversed(range(slot_number, slot_sum + 1)):
for i in range(slot_number, slot_sum + 1):
card_pool.reset()
logger.info("will switch to " + str(i))
card_pool.switch_to_slot(i)
modem_pool = ModemPool(get_devices_ports())
modem_pool.reset_all_modems()
modem_list = init_modems()
# create listeners for chaque modem
# read the contact, and contact the 2 objects together
excel_reader = ExcelHelper()
contacts = excel_reader.read_contacts()
@@ -183,7 +182,7 @@ def start_book():
# get contact for current modem
modem.get_ccid()
# find the contact with ccid
contact = [contact for contact in contacts if contact.ccid == modem.ccid]
contact = [contact for contact in contacts if contact.ccid.replace("F", "") == modem.ccid]
if len(contact) > 0:
modem.phone_number = contact[0].phone
modem.contact = contact[0]
@@ -215,5 +214,5 @@ if __name__ == '__main__':
logger = logging.getLogger()
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
start_listen()
start_book()
# start_book()
# card_pool.switch_to_slot(12)
+6 -18
View File
@@ -50,7 +50,7 @@ def timeout_occurred(serial_modem: SerialModem):
def start_to_handle_sms(serial_modem: SerialModem):
global current_gsm_modem
current_gsm_modem = serial_modem.modem
current_gsm_modem.deleteMultipleStoredSms(memory="SM")
# current_gsm_modem.deleteMultipleStoredSms(memory="MT")
serial_modem.modem.smsReceivedCallback = handle_sms
global is_finished
is_finished = False
@@ -85,26 +85,10 @@ def init_modems() -> list:
modems.append(serial_modem)
return modems
def on_message_received(ch, method, properties, body):
print(str(body))
print(" [x] Received {} {}".format(body, datetime.datetime.now()))
# parse the received message
result = ReserveResultPojo.from_json(body)
result.sim_position = current_sim_position
result.slot_position = current_card_pool_slot
logger.info(result)
firebase_store_manager.save(result)
oracle_log_sender.send_appoint_result(result)
# set the flag to True
global is_finished
is_finished = True
def start_book():
slot_number = 1
slot_sum = 2
for i in reversed(range(slot_number, slot_sum + 1)):
for i in range(slot_number, slot_sum + 1):
card_pool.reset()
logger.info("will switch to " + str(i))
card_pool.switch_to_slot(i)
@@ -122,6 +106,10 @@ def start_book():
try:
# get contact for current modem
modem.get_ccid()
contact = [contact for contact in contacts if contact.ccid.replace("F","") == modem.ccid.replace("F","")]
if len(contact) > 0:
modem.phone_number = contact[0].phone
modem.contact = contact[0]
start_to_handle_sms(modem)
except Exception as error:
print(error)