Пример #1
0
def main(cmdline=None):

    # Initialization
    configureLogging(quiet=False)
    log.info("EB CLI start")

    parameter_pool = ParameterPool()  # pool of all parameters
    validator = ParameterValidator()
    DefaultParameterValue.fill_default(parameter_pool)
    log.debug("Finished initialization")

    try:
        # Parse command line arguments
        cli_parse.parse(parameter_pool, cmdline)
        log.debug("Finished parsing command line arguments.")
        # TODO: set quiet level here.
        if (
            parameter_pool.has(ParameterName.Verbose)
            and parameter_pool.get_value(ParameterName.Verbose) == ServiceDefault.ENABLED
        ):
            prompt.set_level(OutputLevel.Info)
        else:
            prompt.set_level(OutputLevel.ResultOnly)

        validator.validate(parameter_pool, ParameterSource.CliArgument)
        # Compile operation queue
        queue = command.compile_operation_queue(parameter_pool.command)

    except SystemExit as ex:
        _exit(0)

    except BaseException as ex:
        print((misc.to_unicode(ex)))
        log.error(ex)
        _exit(1)

    # Execute queue
    results = []
    try:
        queue.run(parameter_pool, results)
        log.debug("Finished executing operation queue")
    except BaseException as ex:
        print((misc.to_unicode(ex)))
        log.error(ex)
        _exit(1)

    _exit(0)
Пример #2
0
def main(cmdline=None):

    # Initialization
    configureLogging(quiet=False)
    log.info('EB CLI start')

    parameter_pool = ParameterPool()  # pool of all parameters
    validator = ParameterValidator()
    DefaultParameterValue.fill_default(parameter_pool)
    log.debug('Finished initialization')

    try:
        # Parse command line arguments
        cli_parse.parse(parameter_pool, cmdline)
        log.debug('Finished parsing command line arguments.')
        # TODO: set quiet level here.
        if (parameter_pool.has(ParameterName.Verbose) \
                and parameter_pool.get_value(ParameterName.Verbose) == ServiceDefault.ENABLED):
            prompt.set_level(OutputLevel.Info)
        else:
            prompt.set_level(OutputLevel.ResultOnly)

        validator.validate(parameter_pool, ParameterSource.CliArgument)
        # Compile operation queue
        queue = command.compile_operation_queue(parameter_pool.command)

    except SystemExit as ex:
        _exit(0)

    except BaseException as ex:
        print((misc.to_unicode(ex)))
        log.error(ex)
        _exit(1)

    # Execute queue
    results = []
    try:
        queue.run(parameter_pool, results)
        log.debug('Finished executing operation queue')
    except BaseException as ex:
        print((misc.to_unicode(ex)))
        log.error(ex)
        _exit(1)

    _exit(0)