Пример #1
0
 def _get_apps(self, cmd) -> list:
     """
     通过传入的pm list packages命令获取包名列表
     :param cmd:
     :return:
     """
     packages = shellcmd.send_cmd_get_result(self.device.tv_com, cmd)
     ret = list()
     for line in packages.split('\r\n'):
         package = line.split(':', 1)[-1]
         if package in self.app_list:
             ret.append(package)
     return ret
def aria_test(com, count, wait_time, usb):
    i = 0
    usb_aria_root = usb + '/aria_log'
    send_cmd(com,
             'if [ ! -d "' + usb_root + '" ];then mkdir /data/aria_log;fi')
    while i < count:
        print('当前执行次数为: {}'.format(i))
        cur_date_stamp = str(int(time.time()))
        log_file = usb_aria_root + '/第' + str(
            i) + '次_' + cur_date_stamp + '.log'
        send_cmd(
            com,
            'am start com.konka.kkmultiscreen/com.konka.throwingscreen.WelcomeActivity'
        )
        pid = send_cmd_get_result(
            com, 'logcat -v time |grep `ps -A|grep com.konka.kkmultis'
            'creen|busybox awk -F" " \'{print $2}\'` > ' + log_file + ' &')
        time.sleep(wait_time)
        send_cmd(com, 'busybox killall logcat')
        error_1 = send_cmd_get_result(
            com, 'cat ' + log_file +
            '|grep "java.lang.ClassCastException: android.os.BinderProxy cannot be cast to com.konka.kkmultiscreen.DataService"'
        )
        error_2 = send_cmd_get_result(
            com, 'cat ' + log_file +
            '|grep "java.lang.RuntimeException: Unable to start'
            ' service com.konka.kkmultiscreen.tecentscreen.TencentService"')
        if error_1 or error_2:
            print('error_1: ', error_1)
            print('error_2: ', error_2)
            print('第{}次启动过程发现指定异常'.format(i))
        # else:
        #     send_cmd(com, 'rm -rf ' + log_file)
        send_cmd(com, 'am force-stop com.konka.kkmultiscreen')
        # send_cmd(com, 'logcat -c')
        time.sleep(5)
        i += 1
Пример #3
0
 def send_cmd_get_result(self,
                         cmd,
                         wait=0,
                         is_clear_cache=True,
                         timeout=None,
                         is_strip=True):
     self.lock.acquire()
     ret = shellcmd.send_cmd_get_result(com=self.com,
                                        cmd=cmd,
                                        wait=wait,
                                        is_clear_cache=is_clear_cache,
                                        timeout=timeout,
                                        is_strip=is_strip)
     self.lock.release()
     return ret
def init_env(com):
    if int(send_cmd_get_result(com, 'ps -A|grep "S sh"|wc -l')) < 3:
        send_cmd(com, '\rsu\r')
    send_cmd(com, 'echo 0 > /proc/sys/kernel/printk')
    send_cmd(com, 'start logd;logcat -G 2M')
                print('Exception: ' + str(e))
                print('请输入合法的数值,请勿在输入次数时输入非数字的按键')
                continue
        wait_time = input('请输入启动应用后的等待时长:')
        if wait_time:
            try:
                wait_time = int(wait_time)
            except Exception as e:
                print('Exception: ' + str(e))
                print('请输入合法的数值,请勿在输入次数时输入非数字的按键')
                continue
        usb_root = input('请输入日志保存路径:')
        if usb_root:
            try:
                file_num = int(
                    send_cmd_get_result(tv_com,
                                        'ls -l ' + usb_root + '|wc -l'))
                if file_num <= 1:
                    print('请输入正确U盘路径')
                    continue
            except Exception as e:
                print('Exception: ' + str(e))
                print('请输入合法的数值,请勿在输入次数时输入非数字的按键')
                continue
        init_env(tv_com)
        aria_test(tv_com, out_duration_count, wait_time, usb_root)
        close_kk_serial(tv_com)
        import msvcrt
        print('按任意键退出...')
        msvcrt.getch()
        sys.exit()
Пример #6
0
def test(com, count=1000, wait=90):
    res, mes = check_tv_com(com)
    send_cmd(
        com,
        'file="/data/misc/konka/audio_log.txt";if [ ! -f "$file" ];then touch "$file"; fi'
    )
    send_cmd(com, 'chmod 777 /data/misc/konka/audio_log.txt')
    if not res:
        print(mes)
    # 设置音量
    i = 0
    while i < count:
        volume = str(random.randrange(101))
        send_cmd(com, '\rsu\r')
        print('第{}次测试,开始设置音量为{}'.format(i, volume))
        if 'set volume to index=' + volume not in send_cmd_get_result(
                com, 'media volume --stream 3 --set ' + volume):
            print('设置音量失败,请联系对应管理人员')
            send_email(['*****@*****.**', '*****@*****.**'],
                       'AC断电音量检测脚本执行提示邮件', '设置音量失败,请检查权限')
            break
        if 'volume is ' + volume in send_cmd_get_result(
                com, 'media volume --stream 3 --get'):
            print('音量设置成功,开始AC断电')
        send_cmd(
            com,
            'echo "第{}次测试,开始设置音量为{}" >> /data/misc/konka/audio_log.txt'.format(
                i, volume))
        time.sleep(0.5)
        send_cmd(
            com,
            'echo "重启前的audio_stream 日志:" >> /data/misc/konka/audio_log.txt')
        print('audio 信息是:')
        print(send_cmd_get_result(com, 'dumpsys audio | grep stream'))
        time.sleep(0.5)
        send_cmd(
            com,
            'dumpsys audio | grep stream >> /data/misc/konka/audio_log.txt')
        time.sleep(1)
        ac_off()
        time.sleep(2)
        ac_on()
        time.sleep(wait)
        res, mes = check_tv_com(com)
        if not res:
            print(mes)
            print('异常处理中,断电重启')
            ac_on()
            time.sleep(wait)
            res, mes = check_tv_com(com)
            if not res:
                print(mes)
                print('连续2次串口不可以用,脚本中断')
                send_email(['*****@*****.**', '*****@*****.**'],
                           'AC断电音量检测脚本执行提示邮件', 'AC断电后串口不可用,连续2次,请检查')
                break
        send_cmd(
            com,
            'echo "重启后的audio_stream 日志:" >> /data/misc/konka/audio_log.txt')
        send_cmd(
            com,
            'dumpsys audio | grep stream >> /data/misc/konka/audio_log.txt')
        send_cmd(com, 'echo "  " >> /data/misc/konka/audio_log.txt')
        if 'volume is ' + volume in send_cmd_get_result(
                com, 'media volume --stream 3 --get '):
            print('音量检查成功')
            print('audio 信息是:')
            time.sleep(0.5)
            print(send_cmd_get_result(com, 'dumpsys audio | grep stream'))
        else:
            print('音量检查失败')
            print('audio 信息是:')
            time.sleep(0.5)
            print(send_cmd(com, 'dumpsys audio | grep stream'))
            time.sleep(0.5)
            send_email(['*****@*****.**', '*****@*****.**'],
                       'AC断电音量检测脚本执行提示邮件', 'AC断电后音量检查失败,请现场确认')
            break
        i += 1
    if i == count:
        print('执行完成!!!')
        return True
    else:
        print('执行异常!!!')
        return False
Пример #7
0
def _send_cmd_get_result(com, cmd, timeout=60) -> str:
    if isinstance(com, str):
        res = shellcmd.send_cmd_get_result(com, cmd, timeout=timeout)
    else:
        res = com.tv.send_cmd_get_result(cmd, timeout=timeout)
    return res
Пример #8
0
            try:
                in_duration_count = int(in_duration_count)
            except Exception as e:
                print('Exception: ' + str(e))
                print('请输入合法的数值,请勿在输入次数时输入非数字的按键')
                continue
        break
    count = 0
    while count < out_duration_count:
        try:
            print('第' + str(count) + '次开始执行')
            send_cmd(com, '\rsu\r')
            send_cmd(
                com,
                'sh /data/test-相机录制视频.sh ' + str(in_duration_count) + ' &')
            sleep(45)
            while True:
                # 持续检查是否执行完成
                result = send_cmd_get_result(
                    com, 'cat /data/testDir/state_file.txt')
                if result and result == '1':
                    break
                sleep(3)
            count += 1
            send_cmd(com, 'reboot')
            sleep(90)
            print('第' + str(count - 1) + '次执行完成,准备下一次执行')
        except SerialException:
            print('串口异常,请重新执行')
            break