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
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
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()
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))
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
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.' )
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])}')
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)
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)
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()
def write_path_to_console(file_path): write_info(f'File generated at "{file_path}".')
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