def run(self, cmd: str, **kw: Any) -> str: """ """ envstr = " ".join(f"{k}={v}" for k, v in kw.items()) + min(len(kw), 1) * " " LOG.record(shell(f"{envstr}{cmd}")) env = dict(os.environ) env.update(kw) if self.dry_run: return "" result = stdlib_run(cmd, shell=True, stdout=PIPE, stderr=STDOUT, text=True, env=env) # type: ignore if result.returncode != 0: raise RuntimeError(*result.stdout.strip().split("\n")) return cast(str, result.stdout)
def run(cmd: str, fake_cmd: Optional[str] = None, silent: bool = True, **kw: Any) -> str: if not silent: envstr = " ".join(f"{k}={v}" for k, v in kw.items()) if envstr: envstr += " " if fake_cmd: print(f"+{envstr}{fake_cmd}") else: print(f"+{envstr}{cmd}") env = dict(os.environ) env.update(kw) result = stdlib_run(cmd, shell=True, stdout=PIPE, stderr=STDOUT, text=True, env=env) # type: ignore result.check_returncode() return result.stdout or ""
def run(self, cmd: str, fake_cmd: Optional[str] = None, **kw: Any) -> str: envstr = " ".join(f"{k}={v}" for k, v in kw.items()) + min(len(kw), 1) * " " self.record(f"+{envstr}{fake_cmd or cmd}") env = dict(os.environ) env.update(kw) if self.dry_run: return "" result = stdlib_run(cmd, shell=True, stdout=PIPE, stderr=STDOUT, text=True, env=env) # type: ignore self.record(*result.stdout.split("\n")) result.check_returncode() return cast(str, result.stdout)