def onWork(self):
        ret, output = runcmd('adb shell rm "%s"' % Setting.DEVICE_CIT_RESULT_PATH)
        if ret != 0:
            Log.w('CIT RESULT not exists\n%s' % output)

        # TODO: push other files, so
        cmds = []
        cmds.append('adb remount')
        cmds.append('adb push data/audio.primary.imx6.so /system/lib/hw/')
        cmds.append('adb push data/libinputflinger.so /system/lib/')
        cmds.append('adb push data/gralloc.imx6.so /system/lib/hw/')
        success_snipptes = ['remount succeeded', 'KB/s',]
        for cmd in cmds:
            ret, output = runcmd(cmd)
            Log.d(cmd)
            output = output.strip()
            if ret != 0:
                self.err = output
                return self.FAILED
            # match success outputs
            matchsnippet = False
            for snippet in success_snipptes:
                if snippet in output:
                    matchsnippet = True
                    break
            if matchsnippet: continue

            if output:
                self.err = output
                return self.FAILED

        return super(UpdateCITWork, self).onWork()
 def onWork(self):
     ret, output = runcmd('adb remount')
     if ret != 0:
         self.err = u'adb remount 失败'
         return self.FAILED
     ret, output = runcmd('adb shell cat "%s"' % Setting.DEVICE_SN_PATH)
     sn = output.strip()
     if len(sn) > 12:
         self.err = u'不能获取SN'
         return self.FAILED
     else:
         self.ctx.showInfo('GetSn "%s"' % sn)
         self.ctx.setSn(sn)
         return self.SUCCESS
    def onWork(self):
        cmds = []
        cmds.append('adb remount')
        cmds.append('adb push data/cfg80211.ko /system/lib/modules/')
        cmds.append('adb push data/bcmdhd.ko /system/lib/modules/')
        cmds.append('adb push data/nvram.txt /etc/')
        cmds.append('adb push data/fw_bcmdhd.bin /etc/')
        cmds.append('adb push data/wl.dat /data/')
        cmds.append('adb shell "busybox chmod +x /data/wl.dat"')
        cmds.append('adb shell "insmod /system/lib/modules/cfg80211.ko"')
        cmds.append('adb shell "insmod /system/lib/modules/bcmdhd.ko nvram_path=/etc/nvram.txt firmware_path=/etc/fw_bcmdhd.bin"')

        cmds.append('adb shell "busybox ifconfig wlan0 up"')
        cmds.append('adb shell "/data/wl.dat scan"')
        success_snipptes = ['remount succeeded', 'KB/s',
                            '(File exists)']
        for cmd in cmds:
            ret, output = runcmd(cmd)
            Log.d(cmd)
            output = output.strip()
            if ret != 0:
                self.err = output
                return self.FAILED
            # match success outputs
            matchsnippet = False
            for snippet in success_snipptes:
                if snippet in output:
                    matchsnippet = True
                    break
            if matchsnippet: continue

            if output:
                self.err = output
                return self.FAILED

        # wait scan results perpared
        cmd = 'adb shell "/data/wl.dat" scanresults'
        expectstr = '/data/wl.dat: Not Ready'
        while True:
            sleep(1)
            ret, output = runcmd(cmd)
            if expectstr not in output: break

        return BaseWork.onWork(self)
 def onContinue(self, pass_or_failed=None):
     param = self.ui.entry.get().strip()
     try:
         float(param)
     except:
         self.err = u'请输入数值'
         return self.FAILED
     cmd = 'adb shell "echo %s > %s"' % (param, Setting.DEVICE_VCOM_PATH)
     ret, output = runcmd(cmd)
     output = output.strip()
     if ret != 0 or output:
         self.err = u'写入 VCOM 失败'
         self.ctx.showInfo(output)
         return self.FAILED
     ret, output =  runcmd('adb shell "cat %s"' % Setting.DEVICE_VCOM_PATH)
     output = output.strip()
     if output != param:
         self.err = u'写入 VCOM 不一致'
         self.ctx.showInfo(u'"%s"\n"%s"' % (param, output))
         return self.FAILED
     return self.SUCCESS
 def onWork(self):
     ''' Invoke: 工作函数主体, 返回 PAUSE 时等待用户输入entry或者等待点击按钮'''
     if self.ui_hasentry: return BaseWork.PAUSE
     ret, output = runcmd(self.cmd)
     if ret != 0:
         Log.e('[%s]runcmd failed -> %s' % (self.getName(), self.cmd))
         self.err = output
         return BaseWork.FAILED
     m = compile(self.expect).search(output)
     if m:
         Log.d('(SUCCESS)[%s] %s -> match %s' % (self.getName(), self.expect, m.groups()))
         return BaseWork.SUCCESS
     else:
         Log.raw('Output:\n%s' % output)
         Log.e('(FAILED)[%s] %s -> not match' % (self.getName(), self.expect))
         self.err = output
         return BaseWork.FAILED
 def getSn(self):
     ret, output = runcmd('adb shell cat "%s"' % Setting.DEVICE_SN_PATH)
     if not ret: return None
     else: return output