Esempio n. 1
0
def initialise(arguments):
    verbose = arguments['--verbose']
    config_file = arguments['--config']

    if verbose:
        logging.basicConfig(level=logging.DEBUG)

    config = read_authentication(config_file or AUTH_FILE)
    if not config:
        # TODO: prompt for config and store
        pass

    username, password, account_id = tuple(config.get('auth', key)
        for key in config.options('auth'))

    server_parameters = dict(config.items('server-defaults'))
    righteous.init(username, password, account_id, **server_parameters)

    if righteous.login():
        cache_authentication(username, password, account_id,
            config_file or AUTH_FILE)
    else:
        puts_err(colored.red('Authentication failed'))
        exit(2)

    return verbose
Esempio n. 2
0
def initialise(arguments):
    verbose = arguments['--verbose']
    config_file = arguments['--config']

    if verbose:
        logging.basicConfig(level=logging.DEBUG)

    config = read_authentication(config_file or AUTH_FILE)
    if not config:
        error('No configuration found. Either create "%s" or specify a '
              'configuration file with -c FILE' % (AUTH_FILE))

    username, password, account_id = tuple(
        config.get('auth', key) for key in config.options('auth')
    )

    server_parameters = dict(config.items('server-defaults'))
    righteous.initialise(username, password, account_id, **server_parameters)

    if righteous.login():
        cache_authentication(
            username, password, account_id, config_file or AUTH_FILE)
    else:
        error('Authentication failed')

    return verbose