diff --git a/bazel/labgrid/runner/runner.py b/bazel/labgrid/runner/runner.py index 0a15d9fd2f33646cd62f52f7b236f317c866e673..3f9754c7299eb4d5d7818c6e267b4508feb79d27 100644 --- a/bazel/labgrid/runner/runner.py +++ b/bazel/labgrid/runner/runner.py @@ -112,12 +112,12 @@ class Runner: if not download.optional and code == 0: raise e - def run(self, cmd: str, env: Mapping[str, str] = {}) -> int: + def run(self, cmd: str, env: Mapping[str, str] = {}, check=False) -> int: """Run a command on the device with given environment variables.""" cmd = ( f"cd {self._exec_root} && {self._tools.env(self._default_env() | env, cmd)}" ) - out, err, code = self._run(cmd, check=False) + out, err, code = self._run(cmd, check=check) for line in out: stdout.write(f"{line}{linesep}") for line in err: diff --git a/examples/custom-runners/archive-transfer/run.py b/examples/custom-runners/archive-transfer/run.py index 552256db60e85120cf092cc978abda57353c5b7a..b7b92ce7c561f907136d776888b28c3cab433f6e 100644 --- a/examples/custom-runners/archive-transfer/run.py +++ b/examples/custom-runners/archive-transfer/run.py @@ -32,12 +32,11 @@ def main(): uploads = [archive, unzip] r.put(uploads) + r.run(f"{unzip.remote} {archive.remote}", check=True) - code, _ = r.run(f"{unzip.remote} {archive.remote}") - if code != 0: - raise Exception(code) - - code, stdout = r.run(f"{args.program.name} {''.join(args.arguments)}") + code, stdout = r.run( + f"{args.program.name} {''.join(args.arguments)}", check=True + ) with args.out.open("w") as f: print(stdout, file=f)