def wrapper(profile_name, *args, **kwargs):
     profile_name = profile_name or profile_utils.DEFAULT_PROFILE_NAME
     profile = profile_utils.get_profile(profile_name)
     secret = getattr(profile, 'APP_SECRET', None)
     if secret:
         prompt.show_warning(auth_login_msg.format('login', 'authentication'))
     f = func(profile_name, profile, *args, **kwargs)
     if secret:
         profile_utils.remove_profile_value(profile.NAME, secret)
     return f
 def wrapper(profile_name, *args, **kwargs):
     profile_name = profile_name or profile_utils.DEFAULT_PROFILE_NAME
     profile = profile_utils.get_profile(profile_name)
     username = getattr(profile, 'USERNAME', None)
     if username:
         prompt.show_warning(auth_login_msg.format('authentication', 'login'))
     f = func(profile_name, profile, *args, **kwargs)
     if username:
         profile_utils.remove_profile_value(profile.NAME, username)
     return f
 def wrapper(*args, **kwargs):
     action = kwargs.pop('action')
     profile_name = kwargs.pop('profile', None) or profile_utils.DEFAULT_PROFILE_NAME
     if action != 'configure':
         try:
             profile_utils.get_profile(profile_name, info=True)
         except AssertionError:
             prompt.show_warning(prompt.NO_PROFILE_MSG, stop=True)
         except ValueError as e:
             prompt.show_warning(e.args[0], stop=True)
     return func(action, profile_name, *args, **kwargs)
Exemplo n.º 4
0
def configure(profile_name=None, login=False, authenticate=False, log=False):
    profile_name = profile_name or profile_utils.DEFAULT_PROFILE_NAME
    info = {}
    info['APP_ID'], info['DEVICE_ID'] = prompt.retry_once_for_assertions(prompt.configure_prompt)
    remove_info = None
    all_profiles = profile_utils.get_all_profiles()
    if profile_name.lower() in all_profiles:
        prompt.show_warning('Your existing profile "{}" will be overriden.\n'.format(profile_name))
    info.update(configure_login_authenticate(profile_name, login, authenticate))
    info.update(LOG=log)
    is_set = profile_utils.set_profile(info, profile_name)
    if is_set:
        prompt.show_print('Congratulation. You have configured picovico. Run API actions.')
        prompt.show_print('You have the following profile:')
        for profile in profile_utils.get_all_profiles():
            prompt.show_print(profile)
    else:
        prompt.show_print('Something unknown happened. Rerun configure')
 def wrapper(**kwargs):
     action = kwargs.get('project')
     if action != 'begin':
         if not file_utils.has_project_file():
             prompt.show_warning('Please begin your project.', stop=True)
     return func(**kwargs)
def _check_assertion(func, **kwargs):
    try:
        return func(**kwargs)
    except AssertionError as e:
        prompt.show_warning(e.args[0], True)