Ejemplo n.º 1
0
 def __init__(self,
              name: str,
              exec_time: int,
              by: int,
              checker: ck.Checker = None,
              dependent: dp.Dependent = None):
     self.name = name
     self.exec_time = exec_time
     self.by = by
     self.create_time = time_utils.datetime_string(time_utils.TYPE2)
     self.checker = checker if checker else ck.Checker()
     if dependent:
         self.dependent = dependent
     else:
         if self.checker is None:
             raise AttributeError('check is None, scene create fail')
         self.dependent = checker.generate_dependent()
     self.details = dict()
     self.work_threads = list()
     self.start_time = None
     self.cur_count = None
     self.report = None
     self.start_row = None
     self.device = None
     self.fd: fd.FD = None
     self.save_in_usb = False
     self.config_list = [constant.CONFIG_FILE]
     if self.by not in [BY_COUNT, BY_TIME]:
         raise KeyError('illegal by : {}'.format(self.by))
Ejemplo n.º 2
0
    def create_dc_scene(self,devices_list, scene_name,exec_times):
        this_checker = ck.Checker(
            power_off=self.dc_dict["待机是否正常"],
            sub_screen=self.dc_dict["副屏是否正常(外置摄像头保存图片)"],
            power_on=self.dc_dict["开机是否正常"],

        )
        if len(devices_list) == 0:
            self.scene_dcwake = scene_wake.SceneDCWake(
                name=scene_name,
                exec_time=exec_times,
                by=sc.BY_COUNT,
                checker=this_checker,
                mode=dk.MODE_QUICK
                )
            self.scene_dcwake.save()
            self.attribute_init()
            self.creat_success_toast = toast(parent=self, text='DC待机场景\n创建成功!')
            self.creat_success_toast.move(QPoint(self.geometry().left() + self.width() * 0.3, self.geometry().top() + self.height() * 0.3))
            self.creat_success_toast.ocl_signal.connect(self.open_scene_list)
            self.creat_success_toast.setModal(True)
            self.creat_success_toast.exec()
        else:
            self.scene_dcwake = scene_wake.SceneDCWake(
                name="DC待机",
                exec_time=1,
                checker=this_checker,
                mode=dk.MODE_QUICK
        )
            self.attribute_init()
            self.scene_dcwake.device = dv.Device(devices_list[0][0], devices_list[0][1])
            self.checkscene = sceneOneCheck(self.scene_dcwake)
            self.checkscene.reflash_sig.connect(self.showlog)
            self.checkscene.dependent_check_sig.connect(self.check_message)
            self.checkscene.start()
Ejemplo n.º 3
0
 def create_scene_boot_enter(self, devices_list, scene_name, exec_times):
     this_checker = ck.Checker()
     if len(devices_list) == 0:
         self.scene_boot_enter = scene_boot_enter.SceneBootEnter(
             name=scene_name,
             exec_time=exec_times,
             by=sc.BY_COUNT,
             checker=this_checker,
             inner=self.onAndoff_dict["内置应用"],
             third=self.onAndoff_dict["第三方应用"],
             tv=self.onAndoff_dict["信源"])
         self.scene_boot_enter.save()
         self.attribute_init()
         self.creat_success_toast = toast(parent=self, text='开机直达场景\n创建成功!')
         self.creat_success_toast.move(
             QPoint(self.geometry().left() + self.width() * 0.3,
                    self.geometry().top() + self.height() * 0.3))
         self.creat_success_toast.ocl_signal.connect(self.open_scene_list)
         self.creat_success_toast.exec()
     else:
         self.scene_boot_enter = scene_boot_enter.SceneBootEnter(
             name="开机直达",
             exec_time=1,
             checker=this_checker,
             inner=self.onAndoff_dict["内置应用"],
             third=self.onAndoff_dict["第三方应用"],
             tv=self.onAndoff_dict["信源"])
         self.attribute_init()
         self.scene_boot_enter.device = dv.Device(devices_list[0][0],
                                                  devices_list[0][1])
         self.checkscene = sceneOneCheck(self.scene_boot_enter)
         self.checkscene.reflash_sig.connect(self.showlog)
         self.checkscene.dependent_check_sig.connect(self.check_message)
         self.checkscene.start()
Ejemplo n.º 4
0
    def create_onoff_scene(self, devices_list, scene_name, exec_times):
        this_checker = ck.Checker(
            net=self.onAndoff_dict["网络是否回连成功"],
            usb=self.onAndoff_dict["移动存储设备挂载是否成功,U盘个数:"],
            hdmi=self.onAndoff_dict["HDMI出图是否成功"],
            blue_controller=self.onAndoff_dict["遥控器是否回连成功"],
            blue_speaker=self.onAndoff_dict["蓝牙音箱是否回连成功"],
            near=self.onAndoff_dict["近场唤醒是否成功"],
            far=self.onAndoff_dict["远场唤醒是否成功"],
            usb_count=self.usb_count,
            # a2dp_mac=self.a2dp_mac
        )
        if len(devices_list) == 0:
            self.scene_onoff = scene_on_and_off.SceneOnAndOff(
                name=scene_name,
                exec_time=exec_times,
                by=sc.BY_COUNT,
                checker=this_checker,
                mode=self.mode,
                key_set=dict(volume=self.onAndoff_dict["音量+-"],
                             channel=self.onAndoff_dict["频道+-"],
                             pad=self.onAndoff_dict["五维键"],
                             voice=self.onAndoff_dict['语音键']),
                dc_off_interval=self.waittime,
                on2check_interval=self.boottime,
                ad_root=self.ad_root,
                far=self.far)
            self.scene_onoff.save()
            self.attribute_init()
            self.creat_success_toast = toast(parent=self, text='开关机场景\n创建成功!')
            self.creat_success_toast.move(
                QPoint(self.geometry().left() + self.width() * 0.3,
                       self.geometry().top() + self.height() * 0.3))
            self.creat_success_toast.ocl_signal.connect(self.open_scene_list)
            self.creat_success_toast.exec()
        else:
            self.scene_onoff = scene_on_and_off.SceneOnAndOff(
                name="开机压测",
                exec_time=1,
                checker=this_checker,
                mode=self.mode,
                key_set=dict(volume=self.onAndoff_dict["音量+-"],
                             channel=self.onAndoff_dict["频道+-"],
                             pad=self.onAndoff_dict["五维键"],
                             voice=self.onAndoff_dict['语音键']),
                dc_off_interval=self.waittime,
                on2check_interval=self.boottime,
                ad_root=self.ad_root,
                far=self.far)

            self.attribute_init()
            self.scene_onoff.device = dv.Device(devices_list[0][0],
                                                devices_list[0][1])
            self.checkscene = sceneOneCheck(self.scene_onoff)
            self.checkscene.reflash_sig.connect(self.showlog)
            self.checkscene.dependent_check_sig.connect(self.check_message)
            self.checkscene.start()
Ejemplo n.º 5
0
 def create_toscreen_scene(self, devices_list, scene_name, exec_times):
     this_checker = ck.Checker(
         launcher=True,
         # blue_controller=self.online_dict["遥控器是否回连成功"],
         # blue_speaker=self.online_dict["蓝牙音箱是否回连成功"],
         # near=self.online_dict["近场唤醒是否成功"],
         # far=self.online_dict["远场唤醒是否成功"],
     )
     # brand_list = []
     # for channel in ["腾讯视频", "爱奇艺", "酷喵", "QQ音乐MV",
     #                 "QQ音乐", "HDP", "电视家",
     #                 "本地视频", "信源"]:
     #     if self.online_dict[channel] == True:
     #         brand_list.append(channel)
     # print('brand_list', brand_list)
     if self.videomode == True:
         profile = ''
     else:
         profile = ''
     if len(devices_list) == 0:
         self.online_scene = scene_media.SceneMedia(
             name=scene_name,
             exec_time=exec_times,
             by=sc.BY_COUNT,
             profile=profile,
             checker=this_checker,
             brand_list=[],
             performance_str=self.lineEdit_7.text(),
             performance_interval=int(self.lineEdit_6.text()),
             # check_interval=self.lineEdit_2.text()
         )
         self.online_scene.save()
     else:
         self.online_scene = scene_media.SceneMedia(
             name="开机直达",
             exec_time=1,
             profile=profile,
             checker=this_checker,
             brand_list=[],
             performance_str=self.lineEdit_7.text(),
             performance_interval=int(self.lineEdit_6.text()),
             # check_interval=self.lineEdit_2.text()
         )
         task = task_base.TaskBase(name=scene_name,
                                   device=dv.Device(devices_list[0][0],
                                                    devices_list[0][1]),
                                   scene_list=[self.online_scene])
         # task.start()
         try:
             self.test = scene_test(task)
             self.test.sig.connect(self.inform_text)
             self.test.start()
         except:
             print(traceback.format_exc())
Ejemplo n.º 6
0
 def base_deserialize(clazz: type, d: dict):
     """
     静态方法,基本的反序列化操作
     :param clazz:
     :param d:
     :return:
     """
     checker = ck.Checker(**d['checker'])
     dependent = checker.generate_dependent()
     d['checker'] = checker
     d['dependent'] = dependent
     return clazz(**d)
Ejemplo n.º 7
0
    def create_online_scene(self, devices_list, scene_name, exec_times):
        this_checker = ck.Checker(
            blue_controller=self.online_dict["遥控器是否回连成功"],
            blue_speaker=self.online_dict["蓝牙音箱是否回连成功"],
            near=self.online_dict["近场唤醒是否成功"],
            far=self.online_dict["远场唤醒是否成功"],
        )
        brand_list = []
        for channel in [
                "腾讯视频", "爱奇艺", "酷喵", "QQ音乐MV", "QQ音乐", "HDP", "电视家",
                "本地视频_大码率", "本地视频_混合编解码", "信源"
        ]:
            if self.online_dict[channel] == True:
                brand_list.append(channel)
        if len(devices_list) == 0:
            self.online_scene = scene_media.SceneMedia(
                name=scene_name,
                exec_time=exec_times,
                by=sc.BY_TIME,
                checker=this_checker,
                brand_list=brand_list,
                profile=self.lineEdit.text(),
                performance_str=self.performance_str,
                performance_interval=self.performance_interval,
                local_video=self.local_video

                # check_interval=self.lineEdit_2.text()
            )
            self.attribute_init()
            self.online_scene.save()
            self.creat_success_toast = toast(parent=self, text='视频煲机场景\n创建成功!')
            self.creat_success_toast.move(
                QPoint(self.geometry().left() + self.width() * 0.3,
                       self.geometry().top() + self.height() * 0.3))
            self.creat_success_toast.ocl_signal.connect(self.open_scene_list)
            self.creat_success_toast.exec()
        else:
            self.online_scene = scene_media.SceneMedia(
                name="视频煲机",
                exec_time=1,
                checker=this_checker,
                brand_list=brand_list,
                profile=self.lineEdit.text(),
                performance_str=self.performance_str,
                performance_interval=self.performance_interval,
                local_video=self.local_video)
            self.attribute_init()
            self.online_scene.device = dv.Device(devices_list[0][0],
                                                 devices_list[0][1])
            self.checkscene = sceneOneCheck(self.online_scene)
            self.checkscene.reflash_sig.connect(self.showlog)
            self.checkscene.dependent_check_sig.connect(self.check_message)
            self.checkscene.start()
    def create_recorder_scene(self, device_list, curname, times):
        check = ck.Checker()
        self.recorder_scene = SceneRecord(name=curname,
                                          exec_time=times,
                                          checker=check,
                                          scripts=self.script_list)
        self.recorder_scene.save()
        self.creat_success_toast = toast(parent=self, text='录制脚本压测场景\n创建成功!')

        self.creat_success_toast.move(
            self.geometry().left() + self.width() * 0.2,
            self.geometry().top() + self.height() * 0.1)
        self.creat_success_toast.ocl_signal.connect(self.open_scene_list)
        self.creat_success_toast.exec()
    def create_scene_TV(self,devices_list, scene_name,exec_times):
        this_checker = ck.Checker(
            blue_controller=self.choice_dict["遥控器是否回连成功"],
            blue_speaker=self.choice_dict["蓝牙音箱是否回连成功"],
            near=self.choice_dict["近场唤醒是否成功"],
            far=self.choice_dict["远场唤醒是否成功"],
            # a2dp_mac=self.a2dp_mac
        )
        chanel_list = []
        for channel in ['HDMI1','HDMI2','HDMI3','ATV','DTMB']:
            if self.choice_dict[channel] == True:
                chanel_list.append(channel)

        if len(devices_list) == 0:
            self.SceneTV = scene_tv.SceneTV(
                name=scene_name,
                exec_time=exec_times,
                by=sc.BY_TIME,
                checker=this_checker,
                channel_list=chanel_list,
                channel_switch_interval=self.channel_switch_interval,
                performance_interval=self.performance_interval,
                check_interval=self.check_interval,
                performance_str=self.performance_str
            )
            self.SceneTV.save()
            self.attribute_init()
            self.creat_success_toast = toast(parent=self, text='信源压测场景\n创建成功!')
            self.creat_success_toast.move(QPoint(self.geometry().left() + self.width() * 0.3, self.geometry().top() + self.height() * 0.3))
            self.creat_success_toast.ocl_signal.connect(self.open_scene_list)
            self.creat_success_toast.exec()
        else:
            self.SceneTV = scene_tv.SceneTV(
                name="信源煲机",
                exec_time=1,
                checker=this_checker,
                channel_list=chanel_list,
                channel_switch_interval=self.channel_switch_interval,
                performance_interval=self.performance_interval,
                check_interval=self.check_interval,
                performance_str=self.performance_str
            )
            self.attribute_init()
            self.SceneTV.device = dv.Device(devices_list[0][0], devices_list[0][1])
            self.checkscene = sceneOneCheck(self.SceneTV)
            self.checkscene.reflash_sig.connect(self.showlog)
            self.checkscene.dependent_check_sig.connect(self.check_message)
            self.checkscene.start()
Ejemplo n.º 10
0
 def create_monkeylogic_scene(self, devices_list, scene_name, exec_times):
     this_checker = ck.Checker(
         camera=self.monkeyLogic_dict["摄像头是否正常"],
         usb=self.monkeyLogic_dict["USB挂载正常,U盘个数:"],
         far=self.monkeyLogic_dict["远场语音是否唤醒正常"],
         net=self.monkeyLogic_dict['网络连接是否正常'],
         near=self.monkeyLogic_dict["近场语音是否唤醒正常"],
         blue_speaker=self.monkeyLogic_dict['蓝牙音箱是否回连成功'],
         blue_controller=self.monkeyLogic_dict['蓝牙遥控器是否回连成功'],
         usb_count=self.usb_count,
         # a2dp_mac=self.a2dp_mac
     )
     if len(devices_list) == 0:
         self.monkeylogic_scene = scene_monkey.SceneMonkeyLogic(
             name=scene_name,
             exec_time=exec_times,
             by=sc.BY_TIME,
             mode=self.mode,
             checker=this_checker,
             switch_interval=self.switch_interval,
             check_interval=self.check_interval,
             packages=self.packages)
         self.monkeylogic_scene.save()
         self.attribute_init()
         self.creat_success_toast = toast(parent=self,
                                          text='逻辑Monkey场景\n创建成功!')
         self.creat_success_toast.move(
             QPoint(self.geometry().left() + self.width() * 0.3,
                    self.geometry().top() + self.height() * 0.3))
         self.creat_success_toast.ocl_signal.connect(self.open_scene_list)
         self.creat_success_toast.exec()
     else:
         self.monkeylogic_scene = scene_monkey.SceneMonkeyLogic(
             name="逻辑monkey",
             exec_time=1,
             mode=self.mode,
             checker=this_checker,
             switch_interval=self.switch_interval,
             check_interval=self.check_interval,
             packages=self.packages)
         self.attribute_init()
         self.monkeylogic_scene.device = dv.Device(devices_list[0][0],
                                                   devices_list[0][1])
         self.checkscene = sceneOneCheck(self.monkeylogic_scene)
         self.checkscene.reflash_sig.connect(self.showlog)
         self.checkscene.dependent_check_sig.connect(self.check_message)
         self.checkscene.start()
Ejemplo n.º 11
0
 def create_recovery_scene(self, devices_list, scene_name, exec_times):
     this_checker = ck.Checker(
         launcher=self.recover_dict["launcher进入正常"],
         camera=self.recover_dict["摄像头驱动是否正常,是否能升降"],
         usb=self.recover_dict["移动存储设备是否能够成功挂载,U盘个数:"],
         wifi_driver=self.recover_dict["WiFi驱动是否正常"],
         far=self.recover_dict["远场语音是否能唤醒"],
         check_apk=self.recover_dict["检测第三方应用是否存在"],
         install_apk=self.recover_dict["批量安装APK(APK路径:xxx)"],
         usb_count=self.usb_count,
         apk_root=self.apk_root)
     if len(devices_list) == 0:
         self.recovery_scene = scene_recovery.SceneRecovery(
             name=scene_name,
             exec_time=exec_times,
             by=sc.BY_COUNT,
             checker=this_checker,
             retain_app=self.is_save_app,
             serial_open=self.is_open_Serial)
         self.recovery_scene.save()
         self.attribute_init()
         self.creat_success_toast = toast(parent=self, text='系统重置场景\n创建成功!')
         self.creat_success_toast.move(
             QPoint(self.geometry().left() + self.width() * 0.3,
                    self.geometry().top() + self.height() * 0.3))
         self.creat_success_toast.ocl_signal.connect(self.open_scene_list)
         self.creat_success_toast.exec()
     else:
         self.recovery_scene = scene_recovery.SceneRecovery(
             name="恢复出厂设置",
             exec_time=1,
             checker=this_checker,
             retain_app=self.is_save_app,
             serial_open=self.is_open_Serial)
         self.attribute_init()
         self.recovery_scene.device = dv.Device(devices_list[0][0],
                                                devices_list[0][1])
         self.checkscene = sceneOneCheck(self.recovery_scene)
         self.checkscene.reflash_sig.connect(self.showlog)
         self.checkscene.dependent_check_sig.connect(self.check_message)
         self.checkscene.start()
Ejemplo n.º 12
0
def deserialize(d: dict):
    """
    默认的反序列化操作
    :param d:
    :return:
    """
    d = d.copy()
    m = importlib.import_module(d['module'])
    if not hasattr(m, d['clazz']):
        raise ValueError('deserialize fail !')
    d.pop('module')
    dependent = d.pop('dependent')
    clazz = d.pop('clazz')
    create_time = d.pop('create_time')
    d['checker'] = ck.Checker(**d['checker'])
    obj = m.__dict__[clazz](**d)
    obj.create_time = create_time
    for key, value in dependent.items():
        if value:
            setattr(obj.dependent, 'key', value)
    return obj
Ejemplo n.º 13
0
        """
        self.device.tv.send_cmd('setprop persist.app.launch ' +
                                self.selected_app[package][1])
        string = '<?xml version=\'1.0\' encoding=\'utf-8\' standalone=\'yes\' ?>\n<map>\n<string name=\\"boot_' \
                 'enter\\">' + self.selected_app[package][0] + '</string>\n</map>\n'
        self.device.tv.send_cmd('echo "' + string + '" > ' +
                                self.boot_enter_sp)

    def _set_boot_enter_launcher(self):
        try:
            package = 'com.konka.livelauncher'
            self.device.tv.send_cmd('setprop persist.app.launch ' +
                                    self.app_list[package][1])
            string = '<?xml version=\'1.0\' encoding=\'utf-8\' standalone=\'yes\' ?>\n<map>\n<string name=\\"boot_' \
                     'enter\\">' + self.app_list[package][0] + '</string>\n</map>\n'
            self.device.tv.send_cmd('echo "' + string + '" > ' +
                                    self.boot_enter_sp)
        except BaseException as e:
            logging.warning('_set_boot_enter_launcher fail')
            logging.exception(e)


if __name__ == '__main__':
    s = SceneBootEnter(name='123',
                       exec_time=10,
                       inner=True,
                       third=False,
                       tv=True,
                       checker=ck.Checker())
    s.save()
Ejemplo n.º 14
0
    for scene in new_task.scene_list:
        old_task.scene_list.append(scene)


if __name__ == '__main__':
    from task import scene_on_and_off, scene_boot_enter, scene_tv, scene_media, scene_monkey, scene_wake, checker as ck, switch as sw, dc_wake as dk
    from utils import log

    log.init_logging("", output=False)

    scene1 = scene_on_and_off.SceneOnAndOff(
        name='开机压测',
        exec_time=2,
        by=sc.BY_COUNT,
        checker=ck.Checker(
            launcher=True,
            net=True,
            usb=True),
        mode=sw.MODE_DC,
        key_set=dict(volume=True, voice=True),
        on2check_interval=40,
        far=False
    )

    scene2 = scene_boot_enter.SceneBootEnter(
        name='开机直达',
        exec_time=1,
        by=sc.BY_COUNT,
        checker=ck.Checker(),
        inner=True,
        third=True,
        tv=True