예제 #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))
예제 #2
0
 def upgrade():
     self.DeviceListBox.Disable()
     self.upgrade_button.Disable()
     bin_file = self.FilePicker.GetPath()
     log.debug("AR8020 File:%s" % bin_file)
     if bin_file and os.path.exists(bin_file):
         log.debug("AR8020 File:%s" % bin_file)
         os.system(
             Adb.push(local=bin_file,
                      remote="/data/local/tmp/8020.bin",
                      serial=self.DeviceListBox.GetStringSelection()))
         self.open_8020_before_upgrade()
         self.update_8020_state()
         import subprocess
         p = subprocess.Popen(Adb.shell_command(
             cmd="upgrade_ar8020 /data/local/tmp/8020.bin",
             serial=self.DeviceListBox.GetStringSelection()),
                              stdout=subprocess.PIPE,
                              bufsize=1)
         while True:
             data = p.stdout.readline()  # block/wait
             log.debug(repr(data))
             if "get file size" in data:
                 self.ST_Artosyn.SetLabel(u"Upgrading...")
             elif "upgrade successed" in data:
                 self.ST_Artosyn.SetLabel(
                     u"Upgrade complete,Wait for reboot AR8020")
                 break
             else:
                 cur, total = Utility.find_in_string(pattern=pattern,
                                                     string=data)
                 cur, total = float(cur), int(total)
                 self.upgarde_gauge.SetValue(cur / total * 1000)
                 print cur / total * 1000
             time.sleep(0.01)
         os.system(
             Adb.shell_command(
                 cmd=
                 "echo 0 > /sys/bus/platform/drivers/artosyn_ar8020/soc:ar8020/enable",
                 serial=self.DeviceListBox.GetStringSelection()))
         time.sleep(1)
         os.system(
             Adb.shell_command(
                 cmd=
                 "echo 1 > /sys/bus/platform/drivers/artosyn_ar8020/soc:ar8020/enable",
                 serial=self.DeviceListBox.GetStringSelection()))
         self.update_8020_state()
     else:
         log.warn("Can not find Bin File ,Skip.")
     self.DeviceListBox.Enable()
     self.upgrade_button.Enable()
예제 #3
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: