Exemple #1
0
 def stop_exist_uart_log(self):
     self.stop_background_uart_log(self.serial)
     output = os.popen(
         Adb.shell_command(cmd="ps -A |grep uart_log",
                           serial=self.serial)).read()
     for line in output.split('\n'):
         if not line:
             continue
         pid = Utility.find_in_string(re.compile(r'\d+'), line)
         log.info("%s\t>\tpid:%s" % (line, pid))
         Utility.run_cmd(
             Adb.shell_command(cmd='kill -2 %s' % pid, serial=self.serial))
Exemple #2
0
 def set_screenshots(self):
     screenshots_name = "screenshots%s.png" % self.display_id
     save_path = "/data/local/tmp/%s" % screenshots_name
     local_path = os.path.join(TMP, screenshots_name)
     cmd = "screencap -d {id} -p {path}".format(id=self.display_id,
                                                path=save_path)
     os.popen(
         adb.shell_command(cmd=cmd,
                           serial=self.parent.get_device_selection()))
     os.popen(adb.pull(remote=save_path, local=local_path))
     self.image_path = local_path
     self.SetBitmap(self.convert_image())
Exemple #3
0
 def is_ar8020_open(serial):
     log.debug("check the AR 8020 state in device:%s" % serial)
     stdin, stdout, stderr = Utility.run_cmd(
         Adb.shell_command(
             cmd=
             "cat /sys/bus/platform/drivers/artosyn_ar8020/soc:ar8020/enable",
             serial=serial))
     return stdout.read()
Exemple #4
0
 def __upgrade(self):
     bin_file = self.fpc.GetPath()
     if bin_file and os.path.exists(bin_file):
         self.lb_devices.Disable()
         self.upgrade_button.Disable()
         log.debug("Find AR8020 Upgrade File:%s" % bin_file)
         device = self.get_device_selection()
         Utility.run_cmd(
             Adb.push(local=bin_file,
                      remote="/data/local/tmp/8020.bin",
                      serial=device))
         self.open_ar8020(serial=device)
         p = subprocess.Popen(Adb.shell_command(
             cmd="upgrade_ar8020 /data/local/tmp/8020.bin", serial=device),
                              stdout=subprocess.PIPE)
         try:
             while True:
                 data = p.stdout.readline()  # block/wait
                 log.debug(repr(data))
                 if "progress" in data:
                     cur, total = Utility.find_in_string(pattern=pattern,
                                                         string=data)
                     cur, total = float(cur), int(total)
                     self.upgarde_gauge.SetValue(cur / total * 1000)
                     self.state_st.SetLabel(u"升级中...")
                     time.sleep(0.01)
                     continue
                 elif "get version err" in data:
                     self.alert_error("Get Version Error")
                     break
                 elif "upgrade successed" in data:
                     self.state_st.SetLabel(u"升级完成,正在重启。")
                     self.close_ar8020(serial=device)
                     time.sleep(1)
                     self.open_ar8020(serial=device)
                     break
         except Exception, e:
             self.state_st.SetLabel(u"升级失败")
             self.alert_error('{error}\n{data}'.format(error=e.message,
                                                       data=repr(data)))
         finally:
Exemple #5
0
 def start_uart_log(self):
     self.session = subprocess.Popen(Adb.shell_command(cmd='uart_log',
                                                       serial=self.serial),
                                     stdin=subprocess.PIPE,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE,
                                     shell=True)
     wx.CallAfter(self.output.AppendText,
                  u"已开启设备:<%s>的UART LOG\n" % self.serial)
     while True:
         if self.stop_flag:
             break
         if self.session.poll() == 0:
             break
         line = self.session.stdout.readline().strip('\r\n')
         if line:
             wx.CallAfter(
                 self.output.AppendText, '{time} :  {line}\n'.format(
                     time=Utility.get_timestamp("%H_%M_%S"), line=line))
     wx.CallAfter(self.output.AppendText,
                  u"已关闭设备:<%s>的UART LOG\n" % self.serial)
Exemple #6
0
 def on_volume_down(self, event):
     device = self.get_device_selection()
     os.popen(adb.shell_command("input keyevent 25", serial=device))
Exemple #7
0
 def on_root(self, event):
     device = self.get_device_selection()
     os.popen(adb.root(serial=device))
     Utility.append_work(target=self.__refresh_devices, allow_dupl=False)
Exemple #8
0
 def on_power(self, event):
     device = self.get_device_selection()
     os.popen(adb.shell_command("input keyevent 26", serial=device))
Exemple #9
0
 def reboot_to_fastboot(self):
     if self.type == "device":
         self.run_command(adb.reboot(serial=self.serial, mode='bootloader'))
         time.sleep(3)
         self.run_command(fastboot.wait_for_device(serial=self.serial))
Exemple #10
0
 def stop_background_uart_log(serial):
     Utility.run_cmd(Adb.shell_command(cmd="stop uart_log", serial=serial))
Exemple #11
0
 def __switch_on_off_ar8020(serial, on):
     state = '1' if on else '0'
     cmd = "echo %s > /sys/bus/platform/drivers/artosyn_ar8020/soc:ar8020/enable" % state
     Utility.run_cmd(Adb.shell_command(cmd=cmd, serial=serial))