コード例 #1
0
ファイル: help.py プロジェクト: AlexLSB/zendesk_holland
    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()
コード例 #2
0
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
コード例 #3
0
ファイル: help.py プロジェクト: pombredanne/holland
    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())
コード例 #4
0
ファイル: __init__.py プロジェクト: AlexLSB/zendesk_holland
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
コード例 #5
0
ファイル: __init__.py プロジェクト: nwbreneman/holland
def setup_commands():
    """
    Load plugins
    """
    commands = get_commands(include_aliases=False)
    for command_name in commands:
        cmdobj = commands[command_name]()
    return cmdobj
コード例 #6
0
ファイル: __init__.py プロジェクト: holland-backup/holland
def setup_commands():
    """
    Load plugins
    """
    commands = get_commands(include_aliases=False)
    for command_name in commands:
        cmdobj = commands[command_name]()
    return cmdobj
コード例 #7
0
ファイル: __init__.py プロジェクト: nwbreneman/holland
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
コード例 #8
0
ファイル: __init__.py プロジェクト: holland-backup/holland
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