INNER CODE UNIT · Python

quote_command

PKU-EMBL/BASALT · BASALT_setup_China_mainland.py:71

def quote_command(command: Sequence[str]) -> str:
    """Return a shell-readable command without executing it through a shell."""
    return shlex.join([str(item) for item in command])


def run_command(
    command: Sequence[str],
    cwd: Optional[Path] = None,
    env: Optional[Dict[str, str]] = None,
    dry_run: bool = False,
    capture: bool = False,
) -> subprocess.CompletedProcess:
    """Run a command safely, or print it in dry-run mode."""
    location = " (in {})".format(cwd) if cwd else ""
    print("+ {}{}".format(quote_command(command), location))
    if dry_run:
        return subprocess.CompletedProcess(command, 0, stdout="", stderr="")
    try:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…