Esempio n. 1
0
    for available_profile in config.profiles:
        if available_profile.database_username == username:
            value = available_profile.database_password
            break
    else:
        value = get_random_string(16)

    return value


SETUP_PROFILE = options.OverridableOption(
    '--profile',
    prompt='Profile name',
    help='The name of the new profile.',
    required=True,
    type=types.ProfileParamType(cannot_exist=True),
    cls=options.interactive.InteractiveOption)

SETUP_USER_EMAIL = options.USER_EMAIL.clone(
    prompt='Email Address (for sharing data)',
    default=get_config_option('user.email'),
    required_fn=lambda x: get_config_option('user.email') is None,
    required=True,
    cls=options.interactive.InteractiveOption)

SETUP_USER_FIRST_NAME = options.USER_FIRST_NAME.clone(
    prompt='First name',
    default=get_config_option('user.first_name'),
    required_fn=lambda x: get_config_option('user.first_name') is None,
    required=True,
    cls=options.interactive.InteractiveOption)
Esempio n. 2
0
# -*- coding: utf-8 -*-
"""Command line interface `aiida-sssp`."""
import click

from aiida.cmdline.params import options, types


@click.group('aiida-sssp',
             context_settings={'help_option_names': ['-h', '--help']})
@options.PROFILE(type=types.ProfileParamType(load_profile=True))
def cmd_root(profile):  # pylint: disable=unused-argument
    """CLI for the `aiida-sssp` plugin."""
Esempio n. 3
0
###########################################################################
# Copyright (c), The AiiDA team. All rights reserved.                     #
# This file is part of the AiiDA code.                                    #
#                                                                         #
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core #
# For further information on the license, see the LICENSE.txt file        #
# For further information please visit http://www.aiida.net               #
###########################################################################
"""Simple wrapper around Django's `manage.py` CLI script."""
import click

from aiida.cmdline.params import options, types


@click.command()
@options.PROFILE(required=True, type=types.ProfileParamType(load_profile=True))
@click.argument('command', nargs=-1)
def main(profile, command):  # pylint: disable=unused-argument
    """Simple wrapper around the Django command line tool that first loads an AiiDA profile."""
    from django.core.management import execute_from_command_line  # pylint: disable=import-error,no-name-in-module
    from aiida.manage.manager import get_manager

    manager = get_manager()
    manager._load_backend(schema_check=False)  # pylint: disable=protected-access

    # The `execute_from_command` expects a list of command line arguments where the first is the program name that one
    # would normally call directly. Since this is now replaced by our `click` command we just spoof a random name.
    argv = ['basename'] + list(command)
    execute_from_command_line(argv)