Esempio n. 1
0
    def print_config() -> None:
        """Print current config file contents"""

        if ENVIRONMENT.clowder_config is None or not ENVIRONMENT.clowder_config.exists(
        ):
            CONSOLE.stdout(' - No config file found')
            return

        CONSOLE.stdout(fmt.bold('Current config\n'))
        text = ENVIRONMENT.clowder_config.read_text()
        CONSOLE.stdout(fmt.escape(f"{text.strip()}\n"))
Esempio n. 2
0
def run_command(command: str, path: Path, check: bool = False) -> CompletedProcess:
    cmd_env = os.environ.copy()
    cmd_env.update({"CLOWDER_DEBUG": "true"})
    processed_cmd = _process_clowder_commands(command)
    CONSOLE.stdout(fmt.bold(f'> {processed_cmd}'))

    # TODO: Replace universal_newlines with text when Python 3.6 support is dropped
    result = subprocess.run(processed_cmd, cwd=path, shell=True, stdout=PIPE, stderr=STDOUT,
                            universal_newlines=True, env=cmd_env)

    output = result.stdout.strip()
    if output:
        print(output)
    CONSOLE.stdout(f'Return code: {result.returncode}')
    if check:
        assert result.returncode == 0
    return result
Esempio n. 3
0
def h5(message: str, newline: bool = True) -> None:
    if newline:
        CONSOLE.stdout()
    CONSOLE.stdout(fmt.bold(fmt.underline(f'### {message}')))
Esempio n. 4
0
def h2(message: str, newline: bool = True) -> None:
    if newline:
        CONSOLE.stdout()
    CONSOLE.stdout(fmt.bold(message))
    separator(message, '-')
Esempio n. 5
0
def separator(message: str, character: str) -> None:
    sep = character * len(message)
    CONSOLE.stdout(fmt.bold(sep))