在pycharm上运行正常,打包成exe就运行失败,大佬求解

写一个monkey测试程序,在pycharm上运行正常,但打包成exe后就运行出错,大佬求解 

from Adbdevices import get_adb_devices
from Apkuninstall import gat_adb_uninstall
from Runmonkey import gat_run_monkey
import multiprocessing


if __name__ == '__main__':

    packname = []
    a = input('包名:')
    packname.append(a)

    device_id = get_adb_devices()
    process = []

    for i in device_id:
        p = multiprocessing.Process(target=gat_adb_uninstall, args=(packname[0], i))
        process.append(p)
        p.start()

    for proc in process:
        proc.join()


    for i in device_id:
        p = multiprocessing.Process(target=gat_run_monkey,args=(packname[0],i))
        process.append(p)
        p.start()

    for proc in process:
        proc.join()
import subprocess


# 获得设备列表
def get_adb_devices():
    devices = []
    proc = subprocess.Popen('adb devices', stdout=subprocess.PIPE, shell=True)
    for line in proc.stdout.readlines():
        line_str = line.decode(encoding='utf8')
        if '\tdevice' in line_str:
            device_id = line_str.strip().split('\tdevice')[0]
            devices.append(device_id)
    print('devices----》', devices)  # ['127.0.0.1:62001', '127.0.0.1:62025']
    return devices

# 获得设备第三方包名
def get_adb_pack3(device_id):
    pack3_list = []
    proc = subprocess.Popen(f'adb -s {device_id} shell pm list package -3', stdout=subprocess.PIPE, shell=True)
    for pack_line in proc.stdout.readlines():
        pack_str = pack_line.decode(encoding='utf8')
        if '\n' in pack_str:
            pack_listName = pack_str.strip().split('\n')[0]
            pack_name3 = pack_listName.replace("package:", '')
        pack3_list.append(pack_name3)
    return pack3_list
import os

# 安装应用
def gat_install_apk(device_id):
    current_path = os.path.abspath(".")
    # 获取到当前路径下的所有文件
    les = os.listdir(current_path)
    for le in les:
        if fe[len(le) - 3:len(le)] == "apk":
            cmd = "adb -s " + device_id + " install -r " + "\"" + le + "\""
            os.system(cmd)
import os
import sys
from Adbdevices import get_adb_pack3
from Apkinstall import gat_install_apk


# 判断设备是否有安装应用,有卸载重装,没有安装
def gat_adb_uninstall(packname,device_id):
    # 获得设备第三包名列表
    pack3_list = get_adb_pack3(device_id)
    if packname in pack3_list:
        print(f'设备:{device_id},已经安装应用,开始卸载!\n'
              f'————————————————————————————————————————')
        os.system(f"adb -s {device_id} uninstall {packname}")
        print(f'设备:{device_id},应用卸载成功,开始安装!\n'
              f'————————————————————————————————————————')
        gat_install_apk(device_id)
    else:
        print(f"设备:{device_id},没有安装应用,开始安装!\n"
              f"————————————————————————————————————————")
        gat_install_apk(device_id)

    # 判断是否成功安装
    pack3_list = get_adb_pack3(device_id)
    if packname in pack3_list:
        print(f"设备:{device_id},程序已经安装成功!\n"
              f"————————————————————————————————————————")
    else:
        print(f"设备:{device_id},程序还在安装中或者安装失败!程序终止!\n"
              f"————————————————————————————————————————")
        sys.exit()
import subprocess

# 压测执行
def gat_run_monkey(packname,device_id):
    print(f'设备:{device_id},包名:{packname},开始执行压测!\n'
          f'————————————————————————————————————————')

    process = subprocess.Popen("cmd", shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
    commands = (f"adb -s {device_id} shell\n"
                f"monkey -p {packname} -v -v -v --throttle 350 --pct-touch 31 --pct-motion 35 --pct-trackball 30 --pct-appswitch 1 --pct-anyevent 1 --pct-majornav 1 --pct-syskeys 0 --pct-pinchzoom 1 --ignore-crashes --ignore-timeouts --bugreport 1000 >/sdcard/{device_id}_{packname}_monkey.txt\n"
                )
    outs, errs = process.communicate(commands.encode("gbk"))

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值