def report(line): if ok[0]: ok[0] = False config.write_colored_text( f, config.colored(31, '\nInstallation problems:\n\n')) print >> f, line print >> f
def run_toolbox(action_classes, script_name='', show_make_flags=True): """ Provide a command line interface for a list of Actions. Note: strings included in the action_classes list will be printed as help text, for example to display section headings. """ args = configure_making(sys.argv[1:]) commands = { } for item in action_classes: if isinstance(item, str): continue name = item.shell_name() commands[ name ] = item if args == [ '--help-make' ]: help = [ '\n' ] help.append('\nMake options:\n'+Make().describe('', show_help=True, escape_newlines=False)+'\n') config.write_colored_text(sys.stdout, ''.join(help)+'\n\n') sys.exit(1) if not args or args == ['-h'] or args == ['--help']: help = [ '\n' ] for item in action_classes: if isinstance(item, str): help.append(config.wrap(item, 70) + '\n\n') continue name = item.shell_name() help.append(' %s\n' % config.colored(1,name+':')) help.append(config.color_as_comment(config.wrap(item.help_short, 70, ' ')) + '\n\n') if show_make_flags: #help.append('\nMake options:\n'+Make().describe('', show_help=True, escape_newlines=False)+'\n') help.append('\nFor workflow make options type "%s --help-make".\n' % script_name) config.write_colored_text(sys.stdout, ''.join(help)) sys.exit(1) try: command, args = args[0], args[1:] mangled_command = command.lower().rstrip(':') if mangled_command not in commands: raise grace.Error("Don't know how to "+command) except: config.report_exception() sys.exit(1) config.shell_run(commands[mangled_command](), args, (script_name+' ' if script_name else '') + mangled_command+':')
def configure_making(args): """ Configure make options, return remaining arguments. Exits program if options are invalid. """ try: maker = Make() leftovers = maker.parse_partial(args) if leftovers != args: config.write_colored_text(sys.stderr, '\n'+maker.describe('Make options')+'\n') maker.run() return leftovers except: config.report_exception() sys.exit(1)
def configure_making(args): """ Configure make options, return remaining arguments. Exits program if options are invalid. """ try: maker = Make() leftovers = maker.parse_partial(args) if leftovers != args: config.write_colored_text( sys.stderr, '\n' + maker.describe('Make options') + '\n') maker.run() return leftovers except: config.report_exception() sys.exit(1)
def _make_inner(action): timestamp = coordinator().time() assert timestamp > LOCAL.time, 'Time running in reverse.' cores = action.cores_required() if cores > 1: coordinator().trade_cores(1, cores) try: config.write_colored_text(sys.stderr, '\n'+action.describe()+'\n') if LOCAL.abort_make and not selection.matches(LOCAL.do_selection, [action.shell_name()]): raise grace.Error('%s would be run. Stopping here.' % action.ident()) old_status = grace.status(action.shell_name()) try: _run_and_save_state(action, timestamp) finally: grace.status(old_status) finally: if cores > 1: coordinator().trade_cores(cores, 1)
def _make_inner(action): timestamp = coordinator().time() assert timestamp > LOCAL.time, 'Time running in reverse.' cores = action.cores_required() if cores > 1: coordinator().trade_cores(1, cores) try: config.write_colored_text(sys.stderr, '\n'+action.describe()+'\n') if LOCAL.abort_make: raise grace.Error('%s would be run. Stopping here.' % action.ident()) grace.status(action.ident()) try: _run_and_save_state(action, timestamp) finally: grace.status('') finally: if cores > 1: coordinator().trade_cores(cores, 1)
def run_toolbox(action_classes, script_name=''): """ Provide a command line interface for a list of Actions. Note: strings included in the action_classes list will be printed as help text, for example to display section headings. """ commands = { } help = [ '\n' ] for item in action_classes: if isinstance(item, str): help.append(config.wrap(item, 70) + '\n\n') continue name = item.shell_name() commands[ name ] = item help.append(' %s\n' % config.colored(1,name+':')) help.append(config.wrap(item.help_short, 70, ' ') + '\n\n') args = sys.argv[1:] if not args: config.write_colored_text(sys.stdout, ''.join(help)+'\n\n') sys.exit(1) try: command, args = args[0], args[1:] mangled_command = command.lower().rstrip(':') if mangled_command not in commands: raise grace.Error("Don't know how to "+command) except: config.report_exception() sys.exit(1) config.shell_run(commands[mangled_command](), args, (script_name+' ' if script_name else '') + mangled_command+':')
def run_toolbox(action_classes, script_name='', show_make_flags=True): """ Provide a command line interface for a list of Actions. Note: strings included in the action_classes list will be printed as help text, for example to display section headings. """ args = configure_making(sys.argv[1:]) commands = {} for item in action_classes: if isinstance(item, str): continue name = item.shell_name() commands[name] = item if args == ['--help-make']: help = ['\n'] help.append( '\nMake options:\n' + Make().describe('', show_help=True, escape_newlines=False) + '\n') config.write_colored_text(sys.stdout, ''.join(help) + '\n\n') sys.exit(1) if not args or args == ['-h'] or args == ['--help']: help = ['\n'] for item in action_classes: if isinstance(item, str): help.append(config.wrap(item, 70) + '\n\n') continue name = item.shell_name() help.append(' %s\n' % config.colored(1, name + ':')) help.append( config.color_as_comment( config.wrap(item.help_short, 70, ' ')) + '\n\n') if show_make_flags: #help.append('\nMake options:\n'+Make().describe('', show_help=True, escape_newlines=False)+'\n') help.append( '\nFor workflow make options type "%s --help-make".\n' % script_name) config.write_colored_text(sys.stdout, ''.join(help)) sys.exit(1) try: command, args = args[0], args[1:] mangled_command = command.lower().rstrip(':') if mangled_command not in commands: raise grace.Error("Don't know how to " + command) except: config.report_exception() sys.exit(1) config.shell_run(commands[mangled_command](), args, (script_name + ' ' if script_name else '') + mangled_command + ':')
def report(line): if ok[0]: ok[0] = False config.write_colored_text(f,config.colored(31,'\nInstallation problems:\n\n')) print >> f, line print >> f