def cpu_app(): status_shebei = huoqushebeizhuangtai() if status_shebei == 'device': xingneng_bao = xingneng_baoming.get('0.0', END).split()[0] xing = xing_t.get() if len(xingneng_bao) <= 5: messagebox.showwarning('警告', '请检查您的包名') for i in range(int(xing)): nen_cun = getnencun(xingneng_bao) rescv, send, liulang_sum = liulang(xingneng_bao) cpu_caiji = caijicpu(xingneng_bao) neicun_t['state'] = 'normal' neicun_t.insert(tkinter.END, ('Pass值:%s' % nen_cun)) neicun_t.insert(tkinter.END, '\n') neicun_t.see(END) neicun_t['state'] = 'disabled' cpu_t['state'] = 'normal' cpu_t.insert(tkinter.END, ('CPU占有率:%s' % cpu_caiji)) cpu_t.insert(tkinter.END, '\n') cpu_t.see(END) cpu_t['state'] = 'disabled' liulang_t['state'] = 'normal' liulang_t.insert(tkinter.END, ('总流量:%sk,上传流量:%sk,下载流量:%sk' % (liulang_sum, rescv, send))) liulang_t.insert(tkinter.END, '\n') liulang_t.see(END) liulang_t['state'] = 'disabled' xingneng_btn['state'] = 'disabled' xingneng_btn['state'] = 'normal' else: messagebox.showwarning('警告', '设备连接异常 请重新连接设备!')
def cpu_app(): status_shebei = huoqushebeizhuangtai() if status_shebei == 'device': xingneng_bao = xingneng_baoming.get('0.0', END).split()[0] xing = xing_t.get() if len(xingneng_bao) <= 5: messagebox.showwarning('警告', '请检查您的包名') cishu_list = [] cpu_list = [] rescv_list = [] send_list = [] total_list = [] pass_list = [] i = 0 for i in range(int(xing)): nen_cun = getnencun(xingneng_bao) rescv, send, liulang_sum = liulang(xingneng_bao) cpu_caiji = caijicpu(xingneng_bao) neicun_t['state'] = 'normal' pass_list.append(int(nen_cun)) neicun_t.insert(tkinter.END, ('Pass值:%s' % nen_cun)) neicun_t.insert(tkinter.END, '\n') neicun_t.see(END) neicun_t['state'] = 'disabled' cpu_t['state'] = 'normal' cpu_list.append(int(cpu_caiji.split('%')[0])) cpu_t.insert(tkinter.END, ('CPU占有率:%s' % cpu_caiji)) cpu_t.insert(tkinter.END, '\n') cpu_t.see(END) cpu_t['state'] = 'disabled' liulang_t['state'] = 'normal' total_list.append(int(liulang_sum)) rescv_list.append(int(rescv)) send_list.append(int(send)) liulang_t.insert(tkinter.END, ('总流量:%sk,上传流量:%sk,下载流量:%sk' % (liulang_sum, rescv, send))) liulang_t.insert(tkinter.END, '\n') liulang_t.see(END) liulang_t['state'] = 'disabled' xingneng_btn['state'] = 'disabled' i += 1 cishu_list.append(int(i)) getcpu(cishu=cishu_list, start_cpu=cpu_list, recv_list=rescv_list, send_list=send_list, total_list=total_list, Pass_list=pass_list) xingneng_btn['state'] = 'normal' messagebox.showinfo('提醒', '测试完毕,测试报告已经生成!') else: messagebox.showwarning('警告', '设备连接异常 请重新连接设备!')
def qidongapp(): start_tim = [] cishu = [] status_shebei = huoqushebeizhuangtai() if status_shebei == 'device': packname = baoming_t.get('0.0', END) acti = activ_t.get('0.0', END) cish = cishu_ac.get() if len(acti) <= 1 or len(packname) <= 1: messagebox.showinfo('提醒', '包命或者包名activity不能为空') else: if len(cish) <= 1: messagebox.showinfo('提醒', '次数不能为空') else: i = 0 e1['state'] = 'normal' e1.delete(1.0, tkinter.END) sum = 0 for i in range(int(cish)): start_time = starttime_app(packagename=packname, packagenameactivicy=acti) start_tim.append(int(start_time[1])) cishu.append(i) if start_time is None: messagebox.showwarning('警告', '请检查您输入的包或者包的启动activity') break text = '第%s次启动时间:%s' % (i + 1, start_time[1]) sum += int(start_time[1]) e1['state'] = 'normal' e1.insert(tkinter.END, text) e1.insert(tkinter.END, '\n') e1.see(END) btn_start['state'] = 'disabled' e1.insert(tkinter.END, ('平均用时:%s' % (sum / int(cish)))) qidongceshi(cishu=cishu, start=start_tim) messagebox.showinfo('提示', '测试报告已经生成,请到当前目录查看') e1['state'] = 'disabled' btn_start['state'] = 'normal' messagebox.showinfo('通知', '测试已经完成') else: messagebox.showerror('警告', '设备连接异常')
def monkey_app(): status_shebei = huoqushebeizhuangtai() if status_shebei == 'device': try: packname = baoming_t1.get('0.0', END).split()[0] zhongzi = zhongzi_t.get('0.0', END).split()[0] time = time_t.get().split()[0] touch = touch_t.get('0.0', END).split()[0] huadong = huadong_t.get('0.0', END).split()[0] guiji = guiji_t.get('0.0', END).split()[0] xitong = xitong_t.get('0.0', END).split()[0] acti = acti_t.get('0.0', END).split()[0] event = event_t.get('0.0', END).split()[0] log = log_t.get('0.0', END).split()[0] danghang = danghang_t.get('0.0', END).split()[0] if len(packname) <= 5: messagebox.showwarning('提醒', '请正确填写包名') if int(touch) + int(huadong) + int(guiji) + int(danghang) + int( xitong) + int(acti) > 100: messagebox.showerror('提醒', '您输入的所有的事件的比例和不能超过100%') # btn_monkey['state']= 'disabled' adb_monkey(packagename=packname, s_num=zhongzi, throttle=time, pct_touch=touch, pct_motion=huadong, pct_trackball=guiji, pct_nav=danghang, pct_syskeys=xitong, pct_appswitch=acti, num=event, logfilepath=log) # messagebox.showinfo('通知',('测试完毕,日志存放:%s'%log)) # btn_monkey['state']= 'normal' except: messagebox.showwarning('警告', '必须填写monkey相关数据') else: messagebox.showwarning('警告', '设备连接异常 请重新连接设备!')
def teread(): for i in range(1): t = threading.Thread(target=cpu_app, args=()) t.start() def teread_start(): for i in range(1): t = threading.Thread(target=qidongapp, args=()) t.start() if __name__ == '__main__': try: status_shebei = huoqushebeizhuangtai() if status_shebei == 'device': root = tkinter.Tk() root.title('雷子的安卓adb小工具') # root.geometry("1000x900") # root.resizable(width=False, height=False) tkinter.Label( root, text='性能参数展示', fg='red', font=("黑体", 15, "bold"), ).grid(row=0, column=3) cpu_t = tkinter.Text(root, height=5, width=30) cpu_t.grid(row=1, column=2) liulang_t = tkinter.Text(root, height=5, width=40) liulang_t.grid(row=1, column=4)