コード例 #1
0
def login(profile_name=None, username=None, password=None, profile=None, do_prompt=True):
    if do_prompt and not (username and password):
        user, pass_ = prompt.retry_once_for_assertions(prompt.configure_login_info, coerce_password=True, query_password=False)
    if username and not password:
        pass_ = prompt.retry_once_for_assertions(prompt.configure_password_info)
    profile_name = getattr(profile, 'NAME', profile_name)
    pv_cli_utils.auth_action('login', profile_name, username=user, password=pass_)
コード例 #2
0
def configure_login_authenticate(profile_name, login=False, authenticate=False):
    info = {}
    remove_info = None
    if login:
        info['USERNAME'], info['PASSWORD'] = prompt.retry_once_for_assertions(prompt.configure_login_info)
        remove_info = profile_utils.AUTHENTICATE_INFO
        if not info['PASSWORD']:
            info.pop('PASSWORD')
    elif authenticate:
        info['APP_SECRET'] = prompt.retry_once_for_assertions(prompt.configure_secret_info)
        remove_info = profile_utils.LOGIN_INFO
    if remove_info:
        for inf in remove_info:
            profile_utils.remove_profile_value(profile_name, inf)
    return info
コード例 #3
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')
コード例 #4
0
def authenticate(profile_name=None, app_secret=None, profile=None, do_prompt=True):
    if do_prompt and not app_secret:
        app_secret = prompt.retry_once_for_assertions(prompt.configure_secret_info)
    profile_name = getattr(profile, 'NAME', profile_name)
    pv_cli_utils.auth_action('authenticate', profile_name, app_secret=app_secret)