def __init__(self, project=None): super(CommandLine, self).__init__() prj = '' if project is None: try: self.project = Project() projects = self.locateProjects() if len(projects) > 0: prj = ( 'Type ' + term.colourise( '\'load_project <path>\'', fg='yellow' ) + ' to load a project.\n' ) prj += ( 'The current directory contains ' + 'the following projects:\n' ) prj += term.colourise( '\n'.join('\t{0}: {1}'.format( idx+1, path ) for idx, path in enumerate(projects)), fg='yellow' ) self.intro = INTRO_TEMPL % dict( version=_version.__version__, projects=prj, ) except exceptions.ProjectFileException: log.error( 'The project file contains errors, ' + 'fix them and then type \'reload\'' ) except: log.error( 'The software has to terminate due to the following error:' ) log.error(traceback.format_exc()) sys.exit(1) else: self.project = project prj = ( 'Project contains ' + term.colourise( str(len(self.project.get_files())), fg='yellow' ) + ' file(s) and ' + term.colourise( str(len(self.project.get_tests())), fg='yellow' ) + ' test(s).' ) self.intro = INTRO_TEMPL % dict( version=_version.__version__, projects=prj, ) self.test_set = set()
def do_pwd(self, command): print( term.colourise('Working directory: ', fg='yellow') + term.colourise('{0}', fg='green').format(os.getcwd()) )
@wraps(fn) def wrapper(*args, **kwargs): log.debug('USER COMMAND: (' + fn.__name__ + ') ' + args[1]) try: return fn(*args, **kwargs) except: log.error('Command failed due to error:') log.error(traceback.format_exc()) return wrapper SEP = ' ' * 4 INTRO_TEMPL = ( '\n' + '-'*79+'\n' + term.colourise('ChipTools ', fn='bold') + '(version: ' + term.colourise('%(version)s', fg='teal') + ')' + '\n\n' + 'Type ' + term.colourise('\'help\'', fg='yellow') + ' to get started.\n' + '%(projects)s' + '\n' + '-'*79+'\n' ) class CommandLine(cmd.Cmd): def __init__(self, project=None): super(CommandLine, self).__init__() prj = '' if project is None: try: self.project = Project() projects = self.locateProjects()
def do_pwd(self, command): print( term.colourise('Working directory: ', fg='yellow') + term.colourise('{0}', fg='green').format(os.getcwd()))
@wraps(fn) def wrapper(*args, **kwargs): log.debug('USER COMMAND: (' + fn.__name__ + ') ' + args[1]) try: return fn(*args, **kwargs) except: log.error('Command failed due to error:') log.error(traceback.format_exc()) return wrapper SEP = ' ' * 4 INTRO_TEMPL = ('\n' + '-' * 79 + '\n' + term.colourise('ChipTools ', fn='bold') + '(version: ' + term.colourise('%(version)s', fg='teal') + ')' + '\n\n' + 'Type ' + term.colourise('\'help\'', fg='yellow') + ' to get started.\n' + '%(projects)s' + '\n' + '-' * 79 + '\n') class CommandLine(cmd.Cmd): def __init__(self, project=None): super(CommandLine, self).__init__() prj = '' if project is None: try: self.project = Project() projects = self.locateProjects() if len(projects) > 0: prj = ('Type ' + term.colourise('\'load_project <path>\'',