예제 #1
0
    def create(cls, app_name, package_name, begin_time, end_time, user_id, jenkins_url, report_url, mobile_ids,
               parameters, process, type_id, run_time, system_device, login_required, login_username,
               login_password, app_install_required):
        try:
            mobile_ids = ','.join(mobile_ids)
            monkey = Monkey(
                app_name=app_name,
                package_name=package_name,
                begin_time=begin_time,
                end_time=end_time,
                user_id=user_id,
                jenkins_url=jenkins_url,
                report_url=report_url,
                mobile_ids=mobile_ids,
                parameters=parameters,
                process=0,
                type_id=type_id,
                status=Monkey.ACTIVE,
                run_time=run_time,
                system_device=system_device,
                login_required=login_required,
                login_username=login_username,
                login_pasword=login_password,
                app_install_required=app_install_required
            )
            db.session.add(monkey)
            db.session.commit()

            return 0, None
        except Exception as e:
            current_app.logger.error(e)
            current_app.logger.error(traceback.format_exc())
            raise CreateObjectException()
예제 #2
0
 def create(cls, params):
     (data_source, phone_model, apk_version, kernel_version, system_version, thesaurus_version, corpus_version,
      key_9_kernel_click_time_average, key_26_kernel_click_time_average, key_9_kernel_response_time,
      key_26_kernel_response_time, cpu_average, ram_average, battery_use, comment, show_in_chart) = params
     cls.disable_others(apk_version, show_in_chart)
     data_show_response = DataShowResponseLog(
         data_source=data_source,
         phone_model=phone_model,
         apk_version=apk_version,
         kernel_version=kernel_version,
         system_version=system_version,
         thesaurus_version=thesaurus_version,
         corpus_version=corpus_version,
         key_9_kernel_click_time_average=key_9_kernel_click_time_average,
         key_26_kernel_click_time_average=key_26_kernel_click_time_average,
         key_9_kernel_response_time=key_9_kernel_response_time,
         key_26_kernel_response_time=key_26_kernel_response_time,
         ram_average=ram_average,
         cpu_average=cpu_average,
         battery_use=battery_use,
         creator=g.userid,
         comment=comment,
         status=0,
         show_in_chart=show_in_chart,
     )
     try:
         db.session.add(data_show_response)
         db.session.commit()
     except Exception:
         raise CreateObjectException('创建数据失败!')
     return 0
예제 #3
0
    def update(cls, id, params):
        (data_source, phone_model, apk_version, kernel_version, system_version, thesaurus_version, corpus_version,
         key_9_kernel_click_time_average, key_26_kernel_click_time_average, key_9_kernel_response_time,
         key_26_kernel_response_time, cpu_average, ram_average, battery_use, comment, show_in_chart) = params

        data_show = DataShowResponseLog.query.get(id)
        cls.disable_others(apk_version, show_in_chart)
        if not data_show:
            raise CannotFindObjectException('数据不存在!')

        data_show.data_source = data_source
        data_show.phone_model = phone_model
        data_show.apk_version = apk_version
        data_show.kernel_version = kernel_version
        data_show.system_version = system_version
        data_show.thesaurus_version = thesaurus_version
        data_show.corpus_version = corpus_version
        data_show.key_9_kernel_click_time_average = key_9_kernel_click_time_average
        data_show.key_26_kernel_click_time_average = key_26_kernel_click_time_average
        data_show.key_9_kernel_response_time = key_9_kernel_response_time
        data_show.key_26_kernel_response_time = key_26_kernel_response_time
        data_show.ram_average = ram_average
        data_show.cpu_average = cpu_average
        data_show.battery_use = battery_use
        data_show.comment = comment
        data_show.show_in_chart = show_in_chart

        try:
            db.session.add(data_show)
            db.session.commit()
        except Exception:
            raise CreateObjectException('更新数据失败!')
        return 0
예제 #4
0
    def update(cls, id, params):
        (data_source, phone_model, apk_version, kernel_version, system_version, thesaurus_version, corpus_version,
         key_9_and_26, first_word_correct_rate, first_page_correct_rate, comment, show_in_chart) = params

        cls.disable_others(apk_version, show_in_chart)
        data_show = DataShowFirstPageFirstWordCorrectRate.query.get(id)

        if not data_show:
            raise CannotFindObjectException('数据不存在!')
        data_show.data_source = data_source
        data_show.phone_model = phone_model
        data_show.apk_version = apk_version
        data_show.kernel_version = kernel_version
        data_show.system_version = system_version
        data_show.thesaurus_version = thesaurus_version
        data_show.corpus_version = corpus_version
        data_show.key_9_and_26 = key_9_and_26
        data_show.first_word_correct_rate = first_word_correct_rate
        data_show.first_page_correct_rate = first_page_correct_rate
        data_show.comment = comment
        data_show.show_in_chart = show_in_chart
        try:
            db.session.add(data_show)
            db.session.commit()
        except Exception:
            raise CreateObjectException('更新数据失败!')
        return 0
예제 #5
0
 def create(cls, params):
     (data_source, phone_model, apk_version, kernel_version, system_version, thesaurus_version, corpus_version,
      key_9_and_26, first_word_correct_rate, first_page_correct_rate, comment, show_in_chart) = params
     cls.disable_others(apk_version, show_in_chart)
     data_show_response = DataShowFirstPageFirstWordCorrectRate(
         data_source=data_source,
         phone_model=phone_model,
         apk_version=apk_version,
         kernel_version=kernel_version,
         system_version=system_version,
         thesaurus_version=thesaurus_version,
         corpus_version=corpus_version,
         key_9_and_26=key_9_and_26,
         first_word_correct_rate=first_word_correct_rate,
         first_page_correct_rate=first_page_correct_rate,
         creator=g.userid,
         comment=comment,
         status=0,
         show_in_chart=show_in_chart,
     )
     try:
         db.session.add(data_show_response)
         db.session.commit()
     except Exception:
         raise CreateObjectException('创建数据失败!')
     return 0
예제 #6
0
    def update(cls, id, params):
        (data_source, phone_model, apk_version, kernel_version, system_version, thesaurus_version, corpus_version,
         key_9_and_26, average, line_90_percent, line_95_percent, comment, show_in_chart) = params

        cls.disable_others(apk_version, show_in_chart)
        data_show_response = DataShowResponseKernelRecord.query.get(id)

        if not data_show_response:
            raise CannotFindObjectException('数据不存在!')
        data_show_response.data_source = data_source
        data_show_response.phone_model = phone_model
        data_show_response.apk_version = apk_version
        data_show_response.kernel_version = kernel_version
        data_show_response.system_version = system_version
        data_show_response.thesaurus_version = thesaurus_version
        data_show_response.corpus_version = corpus_version
        data_show_response.key_9_and_26 = key_9_and_26
        data_show_response.average = average
        data_show_response.line_90_percent = line_90_percent
        data_show_response.line_95_percent = line_95_percent
        data_show_response.comment = comment
        data_show_response.show_in_chart = show_in_chart
        try:
            db.session.add(data_show_response)
            db.session.commit()
        except Exception:
            raise CreateObjectException('更新数据失败!')
        return 0
예제 #7
0
 def create(cls, params):
     (data_source, phone_model, apk_version, kernel_version, system_version, thesaurus_version, corpus_version,
      key_9_and_26, average, line_90_percent, line_95_percent, comment, show_in_chart) = params
     cls.disable_others(apk_version, show_in_chart)
     data_show_response = DataShowResponseKernelRecord(
         data_source=data_source,
         phone_model=phone_model,
         apk_version=apk_version,
         kernel_version=kernel_version,
         system_version=system_version,
         thesaurus_version=thesaurus_version,
         corpus_version=corpus_version,
         key_9_and_26=key_9_and_26,
         average=average,
         line_90_percent=line_90_percent,
         line_95_percent=line_95_percent,
         creator=g.userid,
         comment=comment,
         status=0,
         show_in_chart=show_in_chart
     )
     try:
         db.session.add(data_show_response)
         db.session.commit()
     except Exception:
         raise CreateObjectException('创建数据失败!')
     return 0
예제 #8
0
 def delete(cls, id):
     data_show_response = DataShowResponseLog.query.get(id)
     data_show_response.status = 1
     try:
         db.session.add(data_show_response)
         db.session.commit()
     except Exception:
         raise CreateObjectException('删除数据失败!')
     return 0
예제 #9
0
 def create_by_object(cls, monkey_device_status):
     try:
         if not isinstance(monkey_device_status, MonkeyDeviceStatus):
             return 102, None
         db.session.add(monkey_device_status)
         return 0, None
     except Exception as e:
         current_app.logger.error(e)
         current_app.logger.error(traceback.format_exc())
         raise CreateObjectException()
예제 #10
0
    def create(cls, data_type, data_value):
        data_field = DataShowFields.query.filter(DataShowFields.data_type == data_type,
                                                 DataShowFields.data_value == data_value).all()
        if data_field:
            raise CreateObjectException(f'数据 {data_value} 已存在')

        data_field = DataShowFields(
            data_type=data_type,
            data_value=data_value
        )
        db.session.add(data_field)
        db.session.commit()
        return 0
예제 #11
0
 def create(cls, params, result, key_id, key_type):
     try:
         t = Jira(
             params=params,
             result=result,
             key_type=key_type,
             key_id=key_id,
         )
         db.session.add(t)
         db.session.commit()
         return 0
     except Exception as e:
         current_app.logger.error(str(e))
         raise CreateObjectException(str(e))
예제 #12
0
    def create(cls, monkey_id, task_id, report_type, report_url):
        try:
            monkey_report = MonkeyReport(
                monkey_id=monkey_id,
                task_id=task_id,
                report_type=report_type,
                report_url=report_url
            )
            db.session.add(monkey_report)
            db.session.commit()

            return 0, None
        except Exception as e:
            current_app.logger.error(e)
            current_app.logger.error(traceback.format_exc())
            raise CreateObjectException()
예제 #13
0
    def create(cls, monkey_id, task_id, error_type, error_message, error_count):
        try:
            monkey_error_log = MonkeyErrorLog(
                monkey_id=monkey_id,
                task_id=task_id,
                error_type=error_type,
                error_message=error_message,
                error_count=error_count
            )
            db.session.add(monkey_error_log)
            db.session.commit()

            return 0, None
        except Exception as e:
            current_app.logger.error(e)
            current_app.logger.error(traceback.format_exc())
            raise CreateObjectException()
예제 #14
0
 def using_device(cls, serial):
     try:
         devices = MonkeyDeviceUsing.query.filter(MonkeyDeviceUsing.serial == serial).all()
         if len(devices) == 0:
             device = MonkeyDeviceUsing(
                 serial=serial,
                 using=MonkeyDeviceUsing.ACTIVE
             )
             db.session.add(device)
             db.session.commit()
         else:
             device = devices[0]
             device.using = MonkeyDeviceUsing.ACTIVE
             db.session.add(device)
             db.session.commit()
         return 0, None
     except Exception as e:
         current_app.logger.error(e)
         current_app.logger.error(traceback.format_exc())
         raise CreateObjectException()