Merge branch 'master' into feature/playwright
This commit is contained in:
+22
-11
@@ -3,7 +3,7 @@ import time
|
||||
|
||||
from pojo.contact_pojo import ContactPojo
|
||||
|
||||
PACKAGE_NAME = "com.lpa.appointement"
|
||||
PACKAGE_NAME = "com.opera.mini.android"
|
||||
ACTIVITY_NAME = "MainActivity"
|
||||
BROADCAST_ACTION = "com.lpa.appointement.broadcast"
|
||||
|
||||
@@ -16,28 +16,39 @@ class Commandor:
|
||||
def start_page(self, contact: ContactPojo):
|
||||
# specifying an explicit component name
|
||||
self.clear_app_data()
|
||||
|
||||
subprocess.call(
|
||||
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell am start -n {}/.{} --es \"first_name\" \"{}\" --es \"last_name\" \"{}\" --es \"phone\" \"{}\" --es \"email\" \"{}\" --es \"passport\" \"{}\"".format(
|
||||
PACKAGE_NAME, ACTIVITY_NAME, contact.first_name, contact.last_name, contact.phone, "{}_{}@gmail.com".format(contact.first_name,contact.last_name), contact.passport), shell=True)
|
||||
cmd = "/Users/panlei/Library/Android/sdk/platform-tools/adb shell am start -n {}/.{} --es \"first_name\" \"{}\" --es \"last_name\" \"{}\" --es \"phone\" \"{}\" --es \"email\" \"{}\" --es \"passport\" \"{}\"".format(
|
||||
PACKAGE_NAME, ACTIVITY_NAME, contact.last_name, contact.first_name, "+33{}".format(contact.phone),
|
||||
"{}_{}@gmail.com".format(contact.first_name, contact.last_name), contact.passport)
|
||||
print("cmd is " + cmd)
|
||||
subprocess.call(cmd, shell=True)
|
||||
pass
|
||||
|
||||
def clear_app_data(self):
|
||||
subprocess.call("/Users/panlei/Library/Android/sdk/platform-tools/adb shell pm clear {}".format(PACKAGE_NAME), shell=True)
|
||||
subprocess.call("/Users/panlei/Library/Android/sdk/platform-tools/adb shell pm clear {}".format(PACKAGE_NAME),
|
||||
shell=True)
|
||||
|
||||
def send_otp(self, otp: str):
|
||||
subprocess.call(
|
||||
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell am broadcast -a {} --es otp \"{}\"".format(BROADCAST_ACTION, otp), shell=True)
|
||||
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell am broadcast -a {} --es otp \"{}\"".format(
|
||||
BROADCAST_ACTION, otp), shell=True)
|
||||
pass
|
||||
|
||||
def reset_air_plan_mode(self):
|
||||
subprocess.call("/Users/panlei/Library/Android/sdk/platform-tools/adb shell settings put global airplane_mode_on 1", shell=True)
|
||||
subprocess.call(
|
||||
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell settings put global airplane_mode_on 1",
|
||||
shell=True)
|
||||
time.sleep(1)
|
||||
subprocess.call("/Users/panlei/Library/Android/sdk/platform-tools/adb shell am broadcast -a android.intent.action.AIRPLANE_MODE", shell=True)
|
||||
subprocess.call(
|
||||
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell am broadcast -a android.intent.action.AIRPLANE_MODE",
|
||||
shell=True)
|
||||
time.sleep(1)
|
||||
subprocess.call("/Users/panlei/Library/Android/sdk/platform-tools/adb shell settings put global airplane_mode_on 0", shell=True)
|
||||
subprocess.call(
|
||||
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell settings put global airplane_mode_on 0",
|
||||
shell=True)
|
||||
time.sleep(1)
|
||||
subprocess.call("/Users/panlei/Library/Android/sdk/platform-tools/adb shell am broadcast -a android.intent.action.AIRPLANE_MODE", shell=True)
|
||||
subprocess.call(
|
||||
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell am broadcast -a android.intent.action.AIRPLANE_MODE",
|
||||
shell=True)
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
+6
-1
@@ -12,16 +12,18 @@ from pojo.ReserveResultPojo import PublishType
|
||||
|
||||
# Log subjects
|
||||
LOG_SUBJECT_EVENT = "EVENT"
|
||||
LOG_SUBJECT_SMS = "SMS"
|
||||
SUBJECT_SIM_INFO = "sim_card"
|
||||
# Log type
|
||||
TYPE_EVENT_CHECK_RESULTS = "EVENT_CHECK_RESULTS"
|
||||
TYPE_EVENT_RESET_ALL_SIM_CARDS = "EVENT_RESET_ALL_SIM_CARDS"
|
||||
TYPE_EVENT_CHANGE_SLOT = "EVENT_CHANGE_SLOT"
|
||||
TYPE_SMS_RECEIVED = "TYPE_SMS_RECEIVED"
|
||||
LOG_ERROR = "ERROR"
|
||||
LOG_TYPE_INFO = "INFO"
|
||||
LOG_APPOINTMENT_ERROR = "APPOINTMENT_ERROR"
|
||||
LOG_APPOINTMENT_TIMEOUT = "TIMEOUT"
|
||||
LOG_APPOINTMENT_SUCCESS = "SUCCESS"
|
||||
SUBJECT_SIM_INFO = "sim_card"
|
||||
|
||||
|
||||
class LogSender:
|
||||
@@ -57,6 +59,9 @@ class LogSender:
|
||||
)
|
||||
return response
|
||||
|
||||
def send_sms_reception_log(self, phone, sms_text):
|
||||
msg = "phone:{}, sms:{}".format(phone, sms_text)
|
||||
self.send_log(msg=msg, subject=LOG_SUBJECT_SMS, type=TYPE_SMS_RECEIVED)
|
||||
|
||||
if __name__ == '__main__':
|
||||
init_logger()
|
||||
|
||||
@@ -11,7 +11,8 @@ import params
|
||||
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 logs.LogSender import LOG_APPOINTMENT_TIMEOUT, LOG_SUBJECT_EVENT, TYPE_EVENT_RESET_ALL_SIM_CARDS, LOG_SUBJECT_SMS, \
|
||||
TYPE_SMS_RECEIVED
|
||||
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
|
||||
@@ -19,7 +20,7 @@ from pojo.serial_modem import SerialModem
|
||||
from logs.AppLogging import init_logger
|
||||
from utils.message_receiver import MessageReceiver
|
||||
|
||||
OTP_TIMEOUT = 80
|
||||
OTP_TIMEOUT = 600
|
||||
is_finished = False
|
||||
commandor = Commandor()
|
||||
contacts = []
|
||||
@@ -42,7 +43,6 @@ def send_command(cmd: str, ser, wait_time_in_s: int = 0) -> bytes:
|
||||
time.sleep(1)
|
||||
count = count + 1
|
||||
msg = ser.read(100)
|
||||
# msg = ser.read(100)
|
||||
print(msg)
|
||||
return msg
|
||||
|
||||
@@ -69,6 +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")
|
||||
serial_modem.modem.smsReceivedCallback = handle_sms
|
||||
global is_finished
|
||||
is_finished = False
|
||||
@@ -93,6 +94,7 @@ def handle_sms(sms):
|
||||
u'== SMS message received ==\nFrom: {0}\nTime: {1}\nMessage:\n{2}\n'.format(sms.number, sms.time, sms.text))
|
||||
# extract the otp number
|
||||
date = str(sms.time)[0:10]
|
||||
params.oracle_log_sender.send_sms_reception_log(sms.number, sms.text)
|
||||
if date == str(datetime.date.today()):
|
||||
logger.info("this sms is for today")
|
||||
if "rendez-vous" in sms.text:
|
||||
@@ -148,23 +150,6 @@ def start_listen():
|
||||
receiver.start_listener(on_message_received)
|
||||
|
||||
|
||||
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
|
||||
global current_card_pool_slot
|
||||
slot_sum = 30
|
||||
# card_pool.switch_to_slot(29)
|
||||
firebase_store_manager.clear_all_sim_info()
|
||||
for i in range(slot_number, slot_sum + 1):
|
||||
card_pool.reset()
|
||||
logger.info("will switch to " + str(i))
|
||||
current_card_pool_slot = i
|
||||
card_pool.switch_to_slot(i)
|
||||
modem_pool = ModemPool(get_devices_ports())
|
||||
modem_pool.reset_all_modems()
|
||||
modem_pool.get_raw_phone_number(i)
|
||||
|
||||
|
||||
def start_book():
|
||||
slot_number = 1
|
||||
slot_sum = 22
|
||||
@@ -214,4 +199,3 @@ if __name__ == '__main__':
|
||||
start_listen()
|
||||
start_book()
|
||||
# card_pool.switch_to_slot(12)
|
||||
|
||||
|
||||
@@ -15,10 +15,16 @@ class SerialModem():
|
||||
self.ccid = ccid
|
||||
|
||||
def get_ccid(self):
|
||||
cmd = "AT+CCID\r"
|
||||
cmd = "AT+CCID"
|
||||
self.modem.connect("0000")
|
||||
print("try to get ccid")
|
||||
response = self.modem.write(cmd, True)
|
||||
self.ccid = response[0].split(" ")[1].replace("\"", "")
|
||||
print("The SIM card ccid is:" + self.ccid)
|
||||
print("The SIM phone number is:" + str(self.modem.ownNumber))
|
||||
# print("try to get phone number")
|
||||
# cmd_phone_number = "AT+CPBS=ON"
|
||||
# openBook = self.modem.write(cmd_phone_number, True)
|
||||
# print("response is :" + str(openBook))
|
||||
# cmd_phone_number = "AT+CNUM"
|
||||
# response2 = self.modem.write(cmd_phone_number, True)
|
||||
# print("The SIM phone number is:" + str(response2))
|
||||
|
||||
@@ -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 = 22
|
||||
slot_sum = 23
|
||||
# card_pool.switch_to_slot(29)
|
||||
params.firebase_store_manager.clear_all_sim_info()
|
||||
for i in range(slot_number, slot_sum + 1):
|
||||
|
||||
Reference in New Issue
Block a user