diff options
| author | zhangchengwei <[email protected]> | 2022-09-07 14:41:45 +0800 |
|---|---|---|
| committer | zhangchengwei <[email protected]> | 2022-09-07 14:41:45 +0800 |
| commit | 08a7053f487622c9120bec00e5589b207f2ba9db (patch) | |
| tree | a3815f3b33b2209aff8ea16752b6d59ecc636a05 | |
| parent | ef34b48f6f0b2a435a69c75cc97f1e0cad49fade (diff) | |
将airtest的变量更改到配置文件中显示,并添加上位机及主动识别网卡和真机信息逻辑
| -rw-r--r-- | control/Airtest_client_upper/__init__.py | 0 | ||||
| -rw-r--r-- | control/Airtest_client_upper/airtest_client_api.py | 46 | ||||
| -rw-r--r-- | control/Airtest_client_upper/airtest_upper_config.ini | 13 | ||||
| -rw-r--r-- | control/Airtest_client_upper/device_info.py | 33 |
4 files changed, 81 insertions, 11 deletions
diff --git a/control/Airtest_client_upper/__init__.py b/control/Airtest_client_upper/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/control/Airtest_client_upper/__init__.py diff --git a/control/Airtest_client_upper/airtest_client_api.py b/control/Airtest_client_upper/airtest_client_api.py index a961425..7fd4a25 100644 --- a/control/Airtest_client_upper/airtest_client_api.py +++ b/control/Airtest_client_upper/airtest_client_api.py @@ -1,4 +1,5 @@ # coding=utf-8 +import sys from gevent import monkey monkey.patch_all() import os.path @@ -9,20 +10,36 @@ from gevent import pywsgi import requests import subprocess from concurrent.futures import ThreadPoolExecutor +from configparser import ConfigParser +import device_info +app = Flask(__name__) +#app.config.from_object("config") +app.config['JSON_AS_ASCII'] = False + +#读取配置文件 +config_parse = ConfigParser() +try: + config_parse.read("airtest_upper_config.ini") +except: + config_parse.read("airtest_upper_config.ini", encoding="utf-8") +airtest_client_path = config_parse.get("airtest_upper_script_control", "airtest_client_path") #airtest控制脚本总控路径 +airtest_server_ip = config_parse.get("airtest_server_info", "airtest_server_ip") #airtest服务端ip +airtest_server_port = config_parse.get("airtest_server_info", "airtest_server_port") #airtest服务器port + #airtest脚本路径 -airtest_client_path = r"D:\App_automation\air_test_auto\control.py" -airtest_server_ip = "192.168.42.7" #airtest_server服务层代理IP -airtest_server_port = 5000 #airtest_server服务器代理端口 +# airtest_client_path = r"D:\App_automation\air_test_auto\control.py" +# airtest_server_ip = "192.168.42.7" #airtest_server服务层代理IP +# airtest_server_port = 5000 #airtest_server服务器代理端口 + + #airtest_server接口uri airtest_server_device_info_url = "/device_info" #airtest_server代理提交设备信息地址 airtest_server_upload = "/upload" -app = Flask(__name__) -app.config['JSON_AS_ASCII'] = False @app.route("/client") def client(): @@ -169,14 +186,21 @@ def current_thread(): current_task.submit(submit_device_info) if __name__ == '__main__': - print(11111111111) + print("airtest_client_upper代理服务正在启动......", "\n网卡信息如下") + eth_info = subprocess.Popen("ipconfig", shell=True, stdout=subprocess.PIPE) + eth_info_result0 = eth_info.stdout.read() + try: + eth_info_result = eth_info_result0.decode() + except: + eth_info_result = eth_info_result0.decode(encoding="gbk") + print(eth_info_result) + #上位机主动识别信息 + print("开始识别已连接的真机和模拟器的信息") + device_info.device_info() #current_thread() - + print("真机和模拟器的信息识别完成.") + print("irtest_client_upper代理服务已启动......") # app.debug = True # app.run(host="0.0.0.0", port=5001) - server = pywsgi.WSGIServer(("0.0.0.0", 5001), app) server.serve_forever() - - - print(22)
\ No newline at end of file diff --git a/control/Airtest_client_upper/airtest_upper_config.ini b/control/Airtest_client_upper/airtest_upper_config.ini new file mode 100644 index 0000000..53f4381 --- /dev/null +++ b/control/Airtest_client_upper/airtest_upper_config.ini @@ -0,0 +1,13 @@ +# coding=utf-8 + + +[airtest_upper_script_control] +#airtest分发脚本总控路径 +airtest_client_path = r"D:\App_automation\air_test_auto\control.py" + +[airtest_server_info] +#airtest服务端代理信息 +airtest_server_ip = "192.168.42.7" +airtest_server_port = 5000 + + diff --git a/control/Airtest_client_upper/device_info.py b/control/Airtest_client_upper/device_info.py new file mode 100644 index 0000000..fede805 --- /dev/null +++ b/control/Airtest_client_upper/device_info.py @@ -0,0 +1,33 @@ +# coding=utf-8 +from airtest.core.api import * +from airtest.core.android.android import Android +from airtest.core.android.adb import ADB +import os +import logging + +def device_info(): + logger =logging.getLogger("airtest") + logger.setLevel("INFO") + + device = ADB() + device_list = [] + device_list_out = [] + + print("先使用airtest的adb连接,识别会更准确......") + device_list_out = [list(i) for i in device.devices()] + + #print(device_list_out) + + for i in device_list_out: + #print(i) + d1 = i[0] + #print(d1) + a = Android(serialno=d1) + #print(a.get_ip_address()) + i.append(a.get_ip_address()) + + print(device_list_out) + + +if __name__ == '__main__': + device_info()
\ No newline at end of file |
