Example #1
0
 def retryWithAuthOrRaise(original_exception):
     # in all cases ask for auth, so that in non-interactive mode a
     # login URL is displayed
     auth.authorizeUser(provider='github', interactive=interactive)
     if not interactive:
         raise original_exception
     else:
         logger.debug('trying with authtoken: %s', settings.getProperty('github', 'authtoken'))
         return fn(*args, **kwargs)
Example #2
0
 def retryWithAuthOrRaise(original_exception):
     # in all cases ask for auth, so that in non-interactive mode a
     # login URL is displayed
     auth.authorizeUser(provider='github', interactive=interactive)
     if not interactive:
         raise original_exception
     else:
         logger.debug('trying with authtoken: %s',
                      settings.getProperty('github', 'authtoken'))
         return fn(*args, **kwargs)
Example #3
0
 def wrapped(*args, **kwargs):
     # auth, , authenticate users, internal
     from yotta.lib import auth
     # if yotta is being run noninteractively, then we never retry, but we
     # do call auth.authorizeUser, so that a login URL can be displayed:
     interactive = globalconf.get('interactive')
     try:
         return fn(*args, **kwargs)
     except requests.exceptions.HTTPError as e:
         if e.response.status_code == requests.codes.unauthorized: #pylint: disable=no-member
             logger.debug('%s unauthorised', fn)
             # any provider is sufficient for registry auth
             auth.authorizeUser(provider=None, interactive=interactive)
             if interactive:
                 logger.debug('retrying after authentication...')
                 return fn(*args, **kwargs)
         raise
Example #4
0
 def wrapped(*args, **kwargs):
     # auth, , authenticate users, internal
     from yotta.lib import auth
     # if yotta is being run noninteractively, then we never retry, but we
     # do call auth.authorizeUser, so that a login URL can be displayed:
     interactive = globalconf.get('interactive')
     try:
         return fn(*args, **kwargs)
     except requests.exceptions.HTTPError as e:
         if e.response.status_code == requests.codes.unauthorized:  #pylint: disable=no-member
             logger.debug('%s unauthorised', fn)
             # any provider is sufficient for registry auth
             auth.authorizeUser(provider=None, interactive=interactive)
             if interactive:
                 logger.debug('retrying after authentication...')
                 return fn(*args, **kwargs)
         raise
Example #5
0
def execCommand(args, following_args):
    registry = args.registry
    if args.apikey:
        registry_access.setAPIKey(registry, args.apikey)
    try:
        provider = None
        if args.github_login:
            provider = 'github'
        return auth.authorizeUser(registry, provider=provider, interactive=args.interactive)
    except auth.AuthTimedOut as e:
        logging.error("Login failed: %s", e)
        return 1
Example #6
0
def execCommand(args, following_args):
    registry = args.registry
    if args.apikey:
        registry_access.setAPIKey(registry, args.apikey)
    try:
        provider = None
        if args.github_login:
            provider = 'github'
        return auth.authorizeUser(registry,
                                  provider=provider,
                                  interactive=args.interactive)
    except auth.AuthTimedOut as e:
        logging.error("Login failed: %s", e)
        return 1