예제 #1
0
def read_pickle(path):
    data = {}
    if operateFile.OperateFile(path).check_file():
        with open(path, 'rb') as f:
            try:
                data = pickle.load(f)
            except EOFError:
                pass
    print(data)
    return data
예제 #2
0
 def write_report_collect(self, json, f=""):
     _read_json_temp = self.read_detail_report(f)
     op = operateFile.OperateFile(f, "w")
     _result = {}
     if len(_read_json_temp) > 0:
         _read_json = eval(_read_json_temp)
         for i in _read_json:
             if i == "test_success" or i == "test_failed" or i == "test_sum":  # 统计总的case的运行次数
                 _result[i] = int(_read_json[i]) + int(json[i])
             else:
                 _result[i] = _read_json[i]
     if len(_result) > 0:
         op.write_txt(str(_result))
     else:
         op.write_txt(str(json))
예제 #3
0
def read_email(Memail):
    if oa.OperateFile(Memail.file, "r").check_file() == False:
        print("文件不存在")
        return
    config = configparser.ConfigParser()
    config.read(Memail.file, encoding='utf-8')
    Memail.report = "report.xlsx"
    Memail.to_addr = eval(config['DEFAULT']['to_addr'])
    Memail.mail_host = config['DEFAULT']['mail_host']
    Memail.mail_user = config['DEFAULT']['mail_user']
    Memail.mail_pass = config['DEFAULT']['mail_pass']
    Memail.port = config['DEFAULT']['port']
    Memail.headerMsg = config['DEFAULT']['headerMsg']
    Memail.attach = config['DEFAULT']['attach']
    return Memail
예제 #4
0
    def write_detail(self, json, f="", key="info"):
        '''

        :param json: 存储的json
        :param f: 存储的文件文字,一般是info,和init的位置
        :param key:  info和init两个值,要和f的路径匹配;REPORT_INFO_PATH对应info,REPORT_INIT对应init
        这里的key就是init,当f的值为REPORT_INFO_PATH,这里
        :return:
        '''
        _read_json_temp = self.read_detail_report(f)
        _result = {}
        if len(_read_json_temp) > 0:
            _read_json = eval(_read_json_temp)
            _read_json[key].append(json)
            _result = _read_json
        else:
            _result[key] = []
            _result[key].append(json)
        op = operateFile.OperateFile(f, "w")
        op.write_txt(str(_result))
        print(_result)
예제 #5
0
 def read_detail_report(self, f=""):
     op = operateFile.OperateFile(f, "r")
     return op.read_txt_row()
예제 #6
0
def read_report(f=""):
    op = OperateFile(f, "r")
    return op.read_txt_row()
예제 #7
0
    b_OperateReport.close()


    # b_email.send_mail(get_email())
def open_web_server():
    web_server = HTTPServer((common.HOST, common.PORT), myserver.myHandler)
    web_server.serve_forever()


if __name__ == '__main__':
    ga = get_devices()
    if adbCommon.attached_devices():
        p = Process(target=open_web_server, args=())
        p.start()

        appium_server = server.AppiumServer(ga)
        appium_server.start_server()
        while not appium_server.is_runnnig():
            time.sleep(2)
        runnerPool()
        appium_server.stop_server()
        subprocess.Popen("taskkill /F /T /PID " + str(p.pid), shell=True)
        # web_server.server_close() #关闭webserver
        OperateFile(common.REPORT_COLLECT_PATH).remove_file()
        OperateFile(common.REPORT_INIT).remove_file()
        OperateFile(common.REPORT_INFO_PATH).remove_file()
        OperateFile(common.CRASH_LOG_PATH).remove_file()

    else:
        print(u"设备不存在")