Esempio n. 1
0
 def _create_config(self):
     try:
         self._config = Config.get_instance()
     except ConfigNotExistsException:
         click.echo(f"No config provided in {config_dir()}")
         if ensure_approval(
                 f"Should a sample file be created in {config_dir()}"):
             config_dir().mkdir(exist_ok=True)
             copyfile(sample_config_path().as_posix(), config_path())
         else:
             raise
         if ensure_approval("Do you want to modify the config file now?"):
             click.edit(filename=config_path().as_posix())
         self._config = Config.get_instance()
Esempio n. 2
0
    def __init__(self):
        self.no_verify = False

        try:
            self.config = Config()
        except ConfigNotExistsException:
            click.echo(f"No config provided in {config_dir()}")
            config_dir().mkdir(exist_ok=True)
            if ensure_approval(
                    f"Should a sample file be created in {config_dir()}"):
                copyfile(sample_config_path().as_posix(), config_path())
            if ensure_approval("Do you want to modify the config file now?"):
                click.edit(filename=config_path().as_posix())
            sys.exit(0)
        self._cluster = None
Esempio n. 3
0
def config_migrate(state: State):
    """Migrate esque config to current version.

    If the user's esque config file is from a previous version, migrate it to the current version.
    A backup of the original config file is created with the same name and the extension .bak"""
    new_path, backup = migration.migrate(config_path())
    click.echo(f"Your config has been migrated and is now at {new_path}. A backup has been created at {backup}.")
Esempio n. 4
0
def esque(state, recreate_config: bool):
    if recreate_config:
        config_dir().mkdir(exist_ok=True)
        if ensure_approval(
                f"Should the current config in {config_dir()} get replaced?",
                no_verify=state.no_verify):
            copyfile(sample_config_path().as_posix(), config_path())
Esempio n. 5
0
def config_recreate(state: State):
    """(Re)create esque config.

    Overwrites the existing esque config file with the sample config. If no esque config file already exists,
    create one with the sample config."""
    config_dir().mkdir(exist_ok=True)
    if ensure_approval(f"Should the current config in {config_dir()} get replaced?", no_verify=state.no_verify):
        copyfile(sample_config_path().as_posix(), config_path())
Esempio n. 6
0
def config_edit(state: State):
    """Opens the user's esque config file in the default editor."""
    old_yaml = config_path().read_text()
    new_yaml, _ = edit_yaml(old_yaml, validator=validation.validate_esque_config)
    config_path().write_text(new_yaml)