Esempio n. 1
0
def gen_install(args):
    write_info(
        'Please review the generated install.yml file and fill in the appropriate information '
        '(app name is required).')

    context = {}
    return context
Esempio n. 2
0
def gen_portal_yaml(args):
    write_info(
        f'A Tethys Portal configuration file is being generated at '
        f'{get_tethys_home_dir() + "/" + FILE_NAMES[GEN_PORTAL_OPTION]}. '
        f'Please review the file and fill in the appropriate settings.')

    context = {'SECRET_KEY': generate_secret_key()}
    return context
Esempio n. 3
0
def sync_tethys_apps_db(**kwargs):
    """Sync the Tethys database with the installed apps and extensions

    Args:
        **kwargs: processed key word arguments from commandline
    """
    write_info(
        'Syncing the Tethys database with installed apps and extensions...')
    load_apps()
    from tethys_apps.harvester import SingletonHarvester
    harvester = SingletonHarvester()
    harvester.harvest()
Esempio n. 4
0
def list_command(args):
    """
    List installed apps.
    """
    load_apps()
    installed_apps = get_installed_tethys_apps()
    installed_extensions = get_installed_tethys_extensions()

    if installed_apps:
        write_info('Apps:')
        for item in installed_apps:
            print('  {}'.format(item))

    if installed_extensions:
        write_info('Extensions:')
        for item in installed_extensions:
            print('  {}'.format(item))
Esempio n. 5
0
def _run_process(args, msg, err_msg='ERROR!!!', exit_on_error=True, **kwargs):
    """Run a process while outputting messages. If error then either exit or return error code.

    Args:
        args: args for process
        msg: Message to output before running process
        err_msg: Message to output if there is an error
        exit_on_error: If True then exit if process returns and error code
        **kwargs: processed key word arguments from commandline

    Returns: error code

    """
    write_info(msg)
    err_code = run_process(args)
    if err_code:
        write_error(err_msg)
        if exit_on_error:
            exit(err_code)

        return err_code
Esempio n. 6
0
def create_portal_superuser(portal_superuser_name='admin',
                            portal_superuser_email='',
                            portal_superuser_password='******',
                            **kwargs):
    """Create a superuser account for Tethys Portal

    Args:
        portal_superuser_name: username for the Tethys Portal superuser account
        portal_superuser_email: email for the Tethys Portal superuser account
        portal_superuser_password: password for the Tethys Portal superuser
        **kwargs: processed key word arguments from commandline
    """
    write_info(
        f'Creating Tethys Portal superuser "{portal_superuser_name}"...')
    load_apps()
    from django.contrib.auth.models import User  # noqa: E402
    try:
        User.objects.create_superuser(portal_superuser_name,
                                      portal_superuser_email,
                                      portal_superuser_password)
    except IntegrityError:
        write_error(
            f'Tethys Portal Superuser "{portal_superuser_name}" already exists.'
        )
Esempio n. 7
0
def get_setting(tethys_settings, key):
    if key == 'all':
        all_settings = {
            k: getattr(settings, k)
            for k in dir(settings)
            if not k.startswith('_') and not k == 'is_overridden'
        }
        write_info(pformat(all_settings))
        return
    try:
        value = getattr(settings, key)
        write_info(f'{key}: {pformat(value)}')
    except AttributeError:
        result = _get_dict_key_handle(tethys_settings, key)
        if result is not None:
            d, k = result
            write_info(f'{key}: {pformat(d[k])}')
Esempio n. 8
0
def _run_process(args, msg, err_msg='ERROR!!!'):
    write_info(msg)
    err_code = run_process(args)
    if err_code:
        write_error(err_msg)
        exit(err_code)
Esempio n. 9
0
def create_portal_superuser(portal_superuser_name='admin', portal_superuser_email='', portal_superuser_password='******',
                            **kwargs):
    write_info(f'Creating Tethys Portal superuser "{portal_superuser_name}"...')
    load_apps()
    from django.contrib.auth.models import User  # noqa: E402
    User.objects.create_superuser(portal_superuser_name, portal_superuser_email, portal_superuser_password)
Esempio n. 10
0
def sync_tethys_apps_db(**kwargs):
    write_info('Syncing the Tethys database with installed apps and extensions...')
    load_apps()
    from tethys_apps.harvester import SingletonHarvester
    harvester = SingletonHarvester()
    harvester.harvest()
Esempio n. 11
0
def write_path_to_console(file_path):
    write_info(f'File generated at "{file_path}".')
Esempio n. 12
0
def gen_portal_yaml(args):
    write_info(f'A Tethys Portal configuration file was generated at {get_tethys_home_dir() + "/portal_config.yml"}. '
               f'Please review the file and fill in the appropriate settings.')

    context = {'SECRET_KEY': generate_secret_key()}
    return context