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 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 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)