def run(self, cmds): d.dbg('PyCmdProcess.run(): %s' % cmds) for key in cmds: # 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)
def make_image(self, images): d.dbg('Broxton.make_image: {}'.format(images)) make_sh = MakeSH(pdt=self._pdt, opt=self._opt, user=self._user) sh = None pre_delete = False for image in images: # pre delete. if image in ['clear', 'clr', 'delete', 'del']: pre_delete = True continue elif image in ['noclear', 'noclr', 'nodelete', 'nodel']: pre_delete = False continue # create and excute make shell d.dbg('create makesh for {}'.format(image)) if type(image) is dict: if 'mmm' in image: sh = MakeSH(pdt=self._pdt, opt=self._opt, user=self._user).create_mmm_sh(image['mmm']) else: d.err('Not support: %s' % str(image)) exit() else: sh = make_sh.create_make_sh(image, pre_delete) # run makesh to build images. make_sh.execute_make_sh(sh)
def __init__(self, url=URL): super(Cwp, self).__init__(url) self._url = url # create cmd process self._cmdHdrs = CmdProcessing() self._cmdHdrs.register_cmd_handler(self.get_cmd_handlers()) d.dbg('Cwp init done!')
def fdel_handler(self, cmds): d.dbg('fdel_handler: {}'.format(cmds)) try: n = len(cmds) if n == 1: self.find_delete('./', cmds[0]) elif n >= 2: self.find_delete(cmds[0], cmds[1]) except KeyError as e: d.err('Error: %s' % e)
def url_handler(self, cmds): d.dbg('url_handler: %s' % cmds) for cmd in cmds: if cmd == 'init': self.repo_init() elif cmd == 'sync': self.repo_sync() elif cmd == 'fsync': self.repo_sync(True)
def avb_make_image(self, image, broxton): # copy image to flashfiles folder cmd = r'cp {out}/{src}.img {flashfiles}/{tar}.img'.format( out=broxton._out, src=image, flashfiles=broxton._flashfiles, tar=image) subprocess.call(cmd, shell=True) d.dbg('avb make image now.') cmd = r'''out/host/linux-x86/bin/avbtool make_vbmeta_image \ --output {}/vbmeta.img \ --include_descriptors_from_image {}/boot.img \ --include_descriptors_from_image {}/system.img \ --include_descriptors_from_image {}/vendor.img \ --include_descriptors_from_image {}/tos.img \ --key external/avb/test/data/testkey_rsa4096.pem \ --algorithm SHA256_RSA4096'''.format( broxton._flashfiles, broxton._flashfiles, broxton._flashfiles, broxton._flashfiles, broxton._flashfiles) subprocess.call(cmd, shell=True)
def parser_cmd_args2(self, cmds): re_dict = re.compile(r'^([\w]+):([\w,\.\/\*\|#-]+)$') re_args = re.compile(r'[\w\.\/\*\|#-]+') re_argv = re.compile('^([\w]+)#([\w,\.\/\*\|-]+)$') output = dict() if len(cmds) == 0: cmds = ['help:help'] for cmd in cmds: dict_cmds = re_dict.match(cmd) if dict_cmds: # dict type k, v = dict_cmds.groups() d.dbg((k, v)) if k in output: for x in re_args.findall(v): output[k].append(x) else: output[k] = re_args.findall(v) else: k = None if k in output: for x in re_args.findall(cmd): output[k].append(x) else: output[k] = re_args.findall(cmd) # parse # argv list_argv = output[k] for index in range(len(list_argv)): find_argv = re_argv.match(list_argv[index]) if find_argv: dict_argv = dict() argv = find_argv.groups() dict_argv[argv[0]] = list(argv[1:]) list_argv[index] = dict_argv d.dbg('parser_cmd_args(): %s' % output) return output
def __init__(self): d.dbg('Parser init done.')
def make_image(self, images): d.dbg('_make_image: get input {}'.format(images)) for image in images.values(): d.dbg('_make_image: make {}'.format(image)) cmd = r'make {}'.format(image) subprocess.call(cmd, shell=True)
def delete(self, f): cmd = r'rm -rf %s' % f d.dbg(cmd) return subprocess.call(cmd, shell=True)
def __init__(self, url): self._url = url d.dbg('RepoHelper init set url={}'.format(url))
def get_cups(self, cmds=None): cmd = r'cat /proc/cpuinfo | grep "processor"| wc -l' d.dbg(cmd) return int(subprocess.check_output(cmd, shell=True))
def find_delete(self, path, name): cmd = r'find %s -name %s | xargs rm -rf {}' % (path, name) d.dbg(cmd) return subprocess.call(cmd, shell=True)
def __init__(self): d.dbg('HwInfo init done!')
def find(self, path, name): cmd = r'find %s -name %s' % (path, name) d.dbg(cmd) return subprocess.call(cmd, shell=True)
def __init__(self): d.dbg('Input init done.') pass
def __init__(self): d.dbg('FileOps init done!')