Пример #1
0
def sendEmail():

    #读取模板
    mail_content = OperateFile.readTemplate(PATH("../result.html"))
    # 读取结果数据
    # 生成每种机型Monkey性能测试表

    workbook = xlrd.open_workbook(PATH("../performance_report.xlsx"))
    result = ""
    for i in range(2, workbook.sheet_by_name("性能数据详情")._cell_values.__len__()):
        result = result + "<tr>"
        for item in workbook.sheet_by_name("性能数据详情")._cell_values[i]:
            result = result + "<td>" + str(item) + "</td>"

        result = result + "</tr>"
    print(result)
    crash = ""

    try:
        for item in workbook.sheet_by_name("崩溃日志")._cell_values:
            crash = crash + "<br/>" + item[0]
    except Exception as e:
        crash = "本次测试未出现崩溃现象!"

    mail_content = mail_content.replace("$testResult", result)
    mail_content = mail_content.replace("$crashLog", crash)
    mm = Mailer("*****@*****.**", "Monkey稳定性测报告", mail_content)
    res = mm.sendMail
    if res:
        print('--------->>邮件发送成功!')
    else:
        print('--------->>邮件发送失败!')
Пример #2
0
def mkdirInit(devices, app, data=None):
    # destroy(devices)
    cpu = PATH("./info/" + devices + "_cpu.pickle")
    men = PATH("./info/" + devices + "_men.pickle")
    flow = PATH("./info/" + devices + "_flow.pickle")
    battery = PATH("./info/" + devices + "_battery.pickle")
    fps = PATH("./info/" + devices + "_fps.pickle")
    app[devices] = {
        "cpu": cpu,
        "men": men,
        "flow": flow,
        "battery": battery,
        "fps": fps,
        "header": get_phome(devices)
    }
    OperateFile(cpu).mkdir_file()
    OperateFile(men).mkdir_file()
    OperateFile(flow).mkdir_file()
    OperateFile(battery).mkdir_file()
    OperateFile(fps).mkdir_file()
    OperateFile(
        PATH("./info/sumInfo.pickle")).mkdir_file()  # 用于记录是否已经测试完毕,里面存的是一个整数
    OperateFile(
        PATH("./info/info.pickle")).mkdir_file()  # 用于记录统计结果的信息,是[{}]的形式

    writeSum(0, data, PATH("./info/sumInfo.pickle"))  # 初始化记录当前真实连接的设备数
Пример #3
0
def Create_pickle(dev, app, data):
    print("创建持久性文件...")
    cpu = PATH("./info/" + dev + "_cpu.pickle")
    men = PATH("./info/" + dev + "_men.pickle")
    flow = PATH("./info/" + dev + "_flow.pickle")
    battery = PATH("./info/" + dev + "_battery.pickle")
    fps = PATH("./info/" + dev + "_fps.pickle")
    time.sleep(2)
    app[dev] = {
        "cpu": cpu,
        "men": men,
        "flow": flow,
        "battery": battery,
        "fps": fps,
        "header": get_phone(dev)
    }
    OperateFile(cpu).mkdir_file()
    OperateFile(men).mkdir_file()
    OperateFile(flow).mkdir_file()
    OperateFile(battery).mkdir_file()
    OperateFile(fps).mkdir_file()
    OperateFile(
        PATH("./info/sumInfo.pickle")).mkdir_file()  # 用于记录是否已经测试完毕,里面存的是一个整数
    OperateFile(
        PATH("./info/info.pickle")).mkdir_file()  # 用于记录统计结果的信息,是[{}]的形式
    writeSum(0, data, PATH("./info/sumInfo.pickle"))  # 初始化记录当前真实连接的设备数
Пример #4
0
def mkdirInit(devices, app, data=None):
    # destroy(devices)
    print 'devices:', devices
    bflag = False
    # if ':'in devices:
    #     print '替换 :'
    #     bflag=True
    #     devices1=devices
    #     devices=devices.replace(':', ' ')  #device 包含':' ,无法写入文件名,因为文件名不能有特殊符号
    cpu = PATH("./info/" + devices + "_cpu.pickle")
    men = PATH("./info/" + devices + "_men.pickle")
    flow = PATH("./info/" + devices + "_flow.pickle")
    battery = PATH("./info/" + devices + "_battery.pickle")
    fps = PATH("./info/" + devices + "_fps.pickle")
    # if bflag :
    #     devices =devices1
    app[devices] = {
        "cpu": cpu,
        "men": men,
        "flow": flow,
        "battery": battery,
        "fps": fps,
        "header": get_phome(devices)
    }
    OperateFile(cpu).mkdir_file()
    OperateFile(men).mkdir_file()  # ????
    OperateFile(flow).mkdir_file()
    OperateFile(battery).mkdir_file()
    OperateFile(fps).mkdir_file()
    OperateFile(
        PATH("./info/sumInfo.pickle")).mkdir_file()  # 用于记录是否已经测试完毕,里面存的是一个整数
    OperateFile(
        PATH("./info/info.pickle")).mkdir_file()  # 用于记录统计结果的信息,是[{}]的形式
    # print "1111111"
    writeSum(0, data, PATH("./info/sumInfo.pickle"))  # 初始化记录当前真实连接的设备数
Пример #5
0
def destroy(devices):
    shutil.rmtree((PATH("../info/")))
    OperateFile(PATH("../info/" + devices + "_cpu.pickle")).remove_file()
    OperateFile(PATH("../info/" + devices + "_men.pickle")).remove_file()
    OperateFile(PATH("../info/" + devices + "_flow.pickle")).remove_file()
    OperateFile(PATH("../info/" + devices + "_battery.pickle")).remove_file()
    OperateFile(PATH("../info/" + devices + "_fps.pickle")).remove_file()
    OperateFile(PATH("../info/info.pickle")).remove_file()
    OperateFile(PATH("../info/sumInfo.pickle")).remove_file()
Пример #6
0
              / _    \  ,' )
             / /"\    \/  ,_\
          __(,/   >  e ) / (_\.oO
          \_ /   (   -,_/    \_/
            U     \_, _)
                   (  /
                    >/
                   (.oO
    *******Welcome to use  monkey test!*******
            '''
    print(ASCIIART)
    info_path=os.path.abspath('.')+"\\info\\"
    device_dir = os.path.exists(info_path)
    if device_dir:
        print("持久性目录info已存在,删除重新创建目录,继续执行测试!")
        OperateFile.delete_file(info_path)
    os.mkdir(info_path)  # 创建持久性目录
    device_list = BaseMonitor.get_devices()
    if ba.attached_devices():
        # 多进程方式实现
        pool = Pool(len(device_list))
        pool.map(start, device_list)
        pool.close()
        pool.join()
        sendEmail()

        #多线程实现方式
        # create_threads_monkey(device_list)


    else: