def setup():
    username = inquirer.text(message="What's your username")
    password = inquirer.password(message="What's your password")
    otc_secret = inquirer.password(message="What's your 2FA secret?")
    session = get_session(username, password, otc_secret)
    if session is None:
        print("Invalid login credentials")
        return
    config_file = inquirer.shortcuts.path(message="Specify config file",
                                          path_type=Path.FILE)
    output_directory = inquirer.shortcuts.path(
        message="Specify output directory", path_type=Path.DIRECTORY)
    brightspace_api = BrightspaceAPI(username, password)
    courses = get_courses_list(brightspace_api)
    selected_courses = inquirer.checkbox(
        message="Select courses to sync (press enter when ready)",
        choices=courses)
    course_ids = [courses[course] for course in selected_courses]
    with open(config_file, "w+") as f:
        f.write(
            json.dumps(
                {
                    "output_directory": output_directory,
                    "courses": course_ids,
                    "credentials": {
                        "username": username,
                        "password": password,
                        "otc_secret": otc_secret
                    }
                },
                indent=4))
    print("Setup complete!")
Exemple #2
0
def configure(args):
    profile = args.profile
    cfg = Configuration()
    params = config_override(cfg.config, profile, args)

    try:
        inquirer.prompt([
            inquirer.Text('url',
                          message='URL',
                          default=params.get('url', ''),
                          validate=validate_url),
            inquirer.Text('aws_profile',
                          message='AWS CLI profile',
                          default=params.get('aws_profile', profile),
                          validate=validate_empty),
            inquirer.Text('username',
                          message='Username',
                          default=params.get('username', ''),
                          validate=validate_empty)
        ],
                        answers=params,
                        raise_keyboard_interrupt=True)
        secrets = SecretsManager(params.get('username'), params.get('url'))
        password = inquirer.password(message='Password',
                                     default=secrets.get('credentials', ''),
                                     validate=validate_empty)

        token = __get_or_refresh_token(params['url'], params['username'],
                                       password, secrets, cfg.configdir,
                                       args.force_refresh, args.headless,
                                       args.spinner)
        sso = SSOClient(token, params['region'])

        instances = sso.get_instances()
        inquirer.prompt([
            inquirer.List('instance_id',
                          message='AWS Account',
                          choices=[(_['name'], _['id']) for _ in instances])
        ],
                        answers=params,
                        raise_keyboard_interrupt=True)

        profiles = sso.get_profiles(params['instance_id'])
        inquirer.prompt([
            inquirer.List('profile_id',
                          message='AWS Profile',
                          choices=[(_['name'], _['id']) for _ in profiles])
        ],
                        answers=params,
                        raise_keyboard_interrupt=True)

        cfg.save()
    except KeyboardInterrupt:
        sys.exit(1)
Exemple #3
0
import os
import sys

sys.path.append(os.path.realpath("."))
import inquirer  # noqa

text = inquirer.text(message="Enter your username")
print(text)
password = (inquirer.password(message="Please enter your password"),)
print(password)
checkbox = inquirer.checkbox(message="Please define your type of project?", choices=["common", "backend", "frontend"])
print(checkbox)
choice = inquirer.list_input("Public or private?", choices=["public", "private"])
print(choice)
correct = inquirer.confirm(
    "This will delete all your current labels and " "create a new ones. Continue?", default=False
)
print(correct)
Exemple #4
0
import os
import sys
sys.path.append(os.path.realpath('.'))

import inquirer  # flake8: noqa

text = inquirer.text(message="Enter your username")
print(text)
password = inquirer.password(message='Please enter your password'),
print(password)
checkbox = inquirer.checkbox(message='Please define your type of project?',
                             choices=['common', 'backend', 'frontend'])
print(checkbox)
choice = inquirer.list_input("Public or private?",
                             choices=['public', 'private'])
print(choice)
correct = inquirer.confirm("This will delete all your current labels and "
                           "create a new ones. Continue?", default=False)
print(correct)