示例#1
0
    def make_image(self, images):
        d.dbg('Broxton.make_image: {}'.format(images))
        make_sh = None
        for image in images:
            d.dbg('create makesh for {}'.format(image))
            if type(image) is dict:
                if 'mmm' in image:
                    make_sh = self.create_mmm_sh(image['mmm'])
                else:
                    d.err('Not support: %s' % str(image))
                    exit()
            else:
                make_sh = self.create_make_sh(image)

            # set run right
            cmd = r'chmod a+x {}'.format(make_sh)
            subprocess.call(cmd, shell=True)
            # run make sh
            cmd = r'./{}'.format(make_sh)
            d.dbg(cmd)
            subprocess.call(cmd, shell=True)
            # delete make sh
            cmd = r'rm -rf {}'.format(make_sh)
            d.dbg(cmd)
            subprocess.call(cmd, shell=True)
示例#2
0
    def run(self, cmds):
        d.dbg('CmdProcessing.run(): %s' % cmds)
        for key in cmds.keys():
            # check help.
            if key == 'help':
                for sub_cmd in cmds[key]:
                    if sub_cmd != 'cfg':  # no show while cfg.
                        d.info('help:[help][,cfg]')
                        d.info('  help: show help')
                        d.info('  cfg : show config info')

            if key in self._cmd_dict:
                d.dbg(self._cmd_dict[key])
                if type(self._cmd_dict[key]) == dict:
                    sub_cmds = self._cmd_dict[key]
                    for sub_key in sub_cmds.iterkeys():
                        f = sub_cmds[sub_key]
                        d.dbg(f(cmds[key]))
                else:
                    t = type(self._cmd_dict[key])
                    if t == list:
                        for f in self._cmd_dict[key]:
                            d.dbg(f(cmds[key]))
                    else:
                        f = self._cmd_dict[key]
                        d.dbg(f(cmds[key]))
            else:
                d.err('No handler for: %s' % key)
示例#3
0
 def find_handler(self, cmds):
     d.dbg('find_handler: {}'.format(cmds))
     try:
         n = len(cmds)
         if n == 1:
             self.find('./', cmds[0])
         elif n >= 2:
             self.find(cmds[0], cmds[1])
     except KeyError as e:
         d.err('Error: %s' % e)
示例#4
0
文件: android.py 项目: SanniZ/mypy3
    def print_log(self, log_type, text=None):
        if log_type == 'logcat':
            cmd = 'adb logcat'
        elif log_type == 'dmesg':
            cmd = 'adb shell dmesg'
        elif log_type == 'kmsg':
            cmd = 'adb shell cat /proc/kmsg'
        else:
            d.err('unknown type!')
            return

        if text != None and len(text) != 0:
            filter_cnt=0
            for i in range(len(text)):
                if text[i] == 'all':
                    cmd = r' {}'.format(cmd)
                    break;
                elif text[i] == 'wait':
                    subprocess.call(r'adb wait-for-device', shell=True)
                    continue
                elif text[i] == 'root':
                    subprocess.call(r'adb root', shell=True)
                    continue
                elif text[i] == 'clear' or text[i] == 'clr':
                    subprocess.call(r'clear', shell=True)
                    continue
                else:
                    if filter_cnt == 0:
                        txt = text[i]
                    else:
                        txt=r'{}|{}'.format(txt, text[i])
                    filter_cnt+=1

            cmd = r'{} | grep --color -iE "{}"'.format(cmd, txt)
            d.info(cmd)
            #self.adb_root()
            subprocess.call(cmd, shell=True)