start_port = args.start_port if not start_port: sys.exit( '请指定报告使用的开始端口,查看帮助:python generate_app_ui_test_report.py --help') else: report_dirs = [] devices_dirs = os.listdir('output/app_ui/') for device_dir in devices_dirs: for report_dir in os.listdir('output/app_ui/' + device_dir): report_dirs.append('output/app_ui/' + device_dir + '/' + report_dir) if 'Windows' == platform.system(): # 初始化进程池 p_pool = Custom_Pool(20) for i in range(len(report_dirs)): port = str(int(start_port) + i) get_allure_process_id_command = 'netstat -ano|findstr "0.0.0.0:%s"' % port try: get_allure_process_id = subprocess.check_output( get_allure_process_id_command, shell=True) get_allure_process_id = get_allure_process_id.decode( 'utf-8') get_allure_process_id = StrTool.getStringWithLBRB( get_allure_process_id, 'LISTENING', '\r\n').strip() kill_allure_process_command = 'taskkill /F /pid %s' % get_allure_process_id try: subprocess.check_call(kill_allure_process_command, shell=True) except:
def generate_windows_reports(report_dir, port): subprocess.check_output("start cmd.exe @cmd /c allure serve -p " + port + " " + report_dir, shell=True) if __name__ == '__main__': report_config = Read_Report_Config().report_config ieport = report_config.web_ui_ie_port chromeport = report_config.web_ui_chrome_port firefoxport = report_config.web_ui_firefox_port if 'Windows' == platform.system(): # 初始化进程池 p_pool = Custom_Pool(3) if ieport: # 获得当前监听ie端口的进程id get_ieport_process_id_command = 'netstat -ano|findstr "0.0.0.0:%s"' % ieport try: get_allure_process_id = subprocess.check_output( get_ieport_process_id_command, shell=True) get_allure_process_id = get_allure_process_id.decode('utf-8') get_allure_process_id = StrTool.getStringWithLBRB( get_allure_process_id, 'LISTENING', '\r\n').strip() kill_allure_process_command = 'taskkill /F /pid %s' % get_allure_process_id try: subprocess.check_call(kill_allure_process_command, shell=True) except: print('关闭allure进程,进程id:' + get_allure_process_id +
if not args.test_type: sys.exit('请指定测试类型,查看帮助:python run_app_ui_test.py --help') keyword=args.keyword dir=args.dir markexpr=args.markexpr capture=args.capture reruns=args.reruns lf=args.lf test_type=args.test_type.lower() devices_info_file=args.devices_info_file if test_type=='phone': if not devices_info_file: sys.exit('请指定多设备并行信息文件,查看帮助:python run_app_ui_test.py --help') # 初始化进程池 p_pool = Custom_Pool(int(Read_APP_UI_Config().app_ui_config.max_device_pool)) devices_info=Read_APP_UI_Devices_Info(devices_info_file).devices_info if os.path.exists('config/app_ui_tmp'): FileTool.truncateDir('config/app_ui_tmp/') else: os.mkdir('config/app_ui_tmp') for i in range(len(devices_info)): device_info=devices_info[i] FileTool.writeObjectIntoFile(device_info,'config/app_ui_tmp/'+str(i)) p=p_pool.apply_async(start_app_device_test,(i,device_info,keyword,dir,markexpr,capture,reruns,lf)) p_pool.close() p_pool.join() else: # 执行pytest前的参数准备 pytest_execute_params = ['-c', 'config/pytest.ini', '-v', '--alluredir', 'output/app_ui/windows'] # 判断目录参数