def run(self, cmd, opts, command=None): commands = get_commands() if not command: print >>sys.stderr, "No command specified" parser.print_help() if not commands: print >>sys.stderr, "No available commands" else: print "Available Commands:" commands = list(set(commands.values())) commands.sort(lambda x,y: cmp(x.name, y.name)) for cls in commands: if cls.aliases: cmdname = "%-13s (%s)" % (cls.name, ','.join(cls.aliases)) else: cmdname = cls.name print " %-19s %s" % (cmdname, cls.description) return 1 if not command in commands: print >>sys.stderr, "No such command: %r" % command return os.EX_TEMPFAIL cmdinst = commands[command]() print cmdinst.help()
def run(args=None): if args is None: args = sys.argv[1:] # Run the requested command commands = get_commands() if not args: args = ['help'] command_name = args[0] if command_name not in commands: print >> sys.stderr, "No such command: %r" % command_name return os.EX_UNAVAILABLE else: cmdobj = commands[command_name]() try: return cmdobj.dispatch(args) except KeyboardInterrupt: LOGGER.info("Interrupt") return os.EX_SOFTWARE except Exception, e: LOGGER.debug("Command %r failed: %r", exc_info=True) print >> sys.stderr, "Command %r failed: %r" % (command_name, e) return os.EX_SOFTWARE
def run(self, cmd, opts, command=None): commands = get_commands() if not command: print("No command specified", file=sys.stderr) parser.print_help() if not commands: print("No available commands", file=sys.stderr) else: print("Available Commands:") commands = list(set(commands.values())) commands.sort(key=lambda x: x.name) for cls in commands: if cls.aliases: cmdname = "%-13s (%s)" % (cls.name, ','.join( cls.aliases)) else: cmdname = cls.name print(" %-19s %s" % (cmdname, cls.description)) return 1 if not command in commands: print("No such command: %r" % command, file=sys.stderr) return os.EX_TEMPFAIL cmdinst = commands[command]() print(cmdinst.help())
def run(args=None): if args is None: args = sys.argv[1:] # Run the requested command commands = get_commands() if not args: args = ['help'] command_name = args[0] if command_name not in commands: print >>sys.stderr, "No such command: %r" % command_name return os.EX_UNAVAILABLE else: cmdobj = commands[command_name]() try: return cmdobj.dispatch(args) except KeyboardInterrupt: LOGGER.info("Interrupt") return os.EX_SOFTWARE except Exception, e: LOGGER.debug("Command %r failed: %r", exc_info=True) print >>sys.stderr, "Command %r failed: %r" % (command_name, e) return os.EX_SOFTWARE
def setup_commands(): """ Load plugins """ commands = get_commands(include_aliases=False) for command_name in commands: cmdobj = commands[command_name]() return cmdobj
def run(opts, args=None): """ Run the target command """ commands = get_commands() cmdobj = commands[opts.command]() try: return cmdobj.dispatch(opts, args) except KeyboardInterrupt: LOGGER.info("Interrupt") return os.EX_SOFTWARE except BaseException: print_help() return 1
def run(opts, args=None): """ Run the target command """ commands = get_commands() cmdobj = commands[opts.command]() try: return cmdobj.dispatch(opts, args) except KeyboardInterrupt: LOG.info("Interrupt") return os.EX_SOFTWARE except BaseException: print_help() return 1