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