Esempio n. 1
0
def main(argv=None):
    if not argv:
        argv = sys.argv
    init_script()
    _init_platform()
    szradm = Szradm(os.path.join(__dir__, 'commands'))
    # If szradm called with no arguments - print help() and all/most used possible commands
    szradm_kwds = command_module.parse_command_line(argv[1:], szradm.help(), options_first=True)
    sys.exit(szradm(**szradm_kwds))
Esempio n. 2
0
def main(argv=None):
    if not argv:
        argv = sys.argv
    init_script()
    _init_platform()
    szradm = Szradm(os.path.join(__dir__, 'commands'))
    # If szradm called with no arguments - print help() and all/most used possible commands
    szradm_kwds = command_module.parse_command_line(argv[1:], szradm.help(), options_first=True)
    sys.exit(szradm(**szradm_kwds))
Esempio n. 3
0
    def __call__(self,
        command=None,
        version=False,
        help=False,
        queryenv=False,
        msgsnd=False,
        qa_report=False,
        repair=False,
        name=None,
        msgfile=None,
        queue=None,
        api_version=None,
        fire_event=None,
        endpoint=None,
        behaviour=None,
        role_name=None,
        with_initializing=None,
        https=None,
        args=None):

        if args is None:
            args = []

        if version:
            print('Szradm version: %s.%s' % self.version)
            return

        if help:
            self.subcommands = list(self.subcommands)
            print(self.help() + self._command_help())
            return

        try:
            # old-style command execution for backward compatibility
            if queryenv:
                if not command:
                    raise command_module.CommandError('No queryenv method given.')
                args = ['fetch', 'command='+command] + args
                return self.run_subcommand('queryenv', args)

            if msgsnd:
                kwds = {'name': name,
                    'msgfile': msgfile,
                    'endpoint': endpoint,
                    'queue': queue}
                return self.run_subcommand('msgsnd', [command] + args, kwds)

            if fire_event:
                return self.run_subcommand('fire-event', [fire_event, command] + args)

            if not command:
                return self(help=True)

            # queryenv shortcuts for table-form output
            if QueryenvCmd.supports_oldstyle_method(command):
                kwds = {'shortcut': True,
                    'name': name,
                    'behaviour': behaviour,
                    'role_name': role_name,
                    'with_initializing': with_initializing,
                    'https': https}
                kwds.update(command_module.parse_command_line(args, self.help()))
                kwds['args'] = args
                try:
                    return self.run_subcommand('queryenv', [command], kwds)
                except command_module.InvalidCall as e:
                    raise command_module.InvalidCall('Invalid call', usage=self.help())

            # Standard command execution style
            return self.run_subcommand(command, args)

        except (command_module.UnknownCommand, command_module.InvalidCall) as e:
            message = '\n'.join((str(e), e.usage))
            raise e.__class__(message)

        except command_module.CommandError as e:
            # except-section for user-defined exceptions, semantic errors, etc.
            raise command_module.CommandError(str(e))
Esempio n. 4
0
    def __call__(self, 
        command=None,
        version=False,
        help=False,
        queryenv=False,
        msgsnd=False,
        qa_report=False,
        repair=False,
        name=None,
        msgfile=None,
        queue=None,
        api_version=None,
        fire_event=None,
        endpoint=None,
        behaviour=None,
        role_name=None,
        with_initializing=None,
        https=None,
        args=[]):

        if version:
            print 'Szradm version: %s.%s' % self.version
            return

        if help:
            self.subcommands = list(self.subcommands)
            print self.help() + self._command_help()
            return

        try:
            # old-style command execution for backward compatibility
            if queryenv:
                if not command:
                  raise command_module.CommandError('No queryenv method given.')
                args = ['fetch', 'command='+command] + args
                return self.run_subcommand('queryenv', args)

            if msgsnd:
                kwds = {'name': name,
                    'msgfile': msgfile,
                    'endpoint': endpoint,
                    'queue': queue}
                return self.run_subcommand('msgsnd', [command] + args, kwds)

            if fire_event:
                return self.run_subcommand('fire-event', [fire_event, command] + args)

            if not command:
                return self(help=True)

            # queryenv shortcuts for table-form output
            if QueryenvCmd.supports_oldstyle_method(command):
                kwds = {'shortcut': True,
                    'name': name,
                    'behaviour': behaviour,
                    'role_name': role_name,
                    'with_initializing': with_initializing,
                    'https': https}
                kwds.update(command_module.parse_command_line(args, self.help()))
                kwds['args'] = args
                try:
                    return self.run_subcommand('queryenv', [command], kwds)
                except command_module.InvalidCall, e:
                    raise command_module.InvalidCall('Invalid call', usage=self.help())

            # Standard command execution style
            return self.run_subcommand(command, args)