aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-06-02 21:56:49 +0200
committerBryan Gardiner <bog@khumba.net>2024-07-19 20:30:21 -0700
commit424f8f66d0b93946a4bd215727e722173d2263f3 (patch)
tree65c20bbba6c54bc520ad4bde923d2672c65126f2
parent8d49b3f8c81fa2a960f0121f33dc6ef61e55f2e0 (diff)
downloadlazygl2srht-424f8f66d0b93946a4bd215727e722173d2263f3.tar.gz
fix: handle a failure to run hut subprocess well
Print the return and stderr of the failed subprocess.
-rwxr-xr-ximport_issues.py41
1 files changed, 23 insertions, 18 deletions
diff --git a/import_issues.py b/import_issues.py
index c0910ae..93c4128 100755
--- a/import_issues.py
+++ b/import_issues.py
@@ -171,7 +171,7 @@ def get_labels(tracker: str) -> list[dict[str, str]]:
)
except subprocess.CalledProcessError as ex:
raise RuntimeError(
- f"hut failed with excitcode {ex.returncode} and stderr:\n{ex.stderr}"
+ f"hut failed with excitcode {ex.returncode}\n\nstdout:\n{ex.stdout}\n\nand stderr:\n{ex.stderr}"
) from ex
data = json.loads(ret.stdout)
return data["me"]["tracker"]["labels"]["results"]
@@ -271,23 +271,28 @@ def run_hut(cmds, tracker, msg, args=None, delay=None):
)
if args is None:
args = []
- if msg is None:
- res = subprocess.run(
- ["hut", "todo"] + cmds + ["-t", tracker] + args,
- check=True,
- encoding="utf-8",
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
- else:
- res = subprocess.run(
- ["hut", "todo"] + cmds + ["-t", tracker, "--stdin"] + args,
- check=True,
- encoding="utf-8",
- input=msg,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ try:
+ if msg is None:
+ res = subprocess.run(
+ ["hut", "todo"] + cmds + ["-t", tracker] + args,
+ check=True,
+ encoding="utf-8",
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+ else:
+ res = subprocess.run(
+ ["hut", "todo"] + cmds + ["-t", tracker, "--stdin"] + args,
+ check=True,
+ encoding="utf-8",
+ input=msg,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+ except subprocess.CalledProcessError as ex:
+ raise RuntimeError(
+ f"hut failed with excitcode {ex.returncode}\n\nstdout:\n{ex.stdout}\n\nand stderr:\n{ex.stderr}"
+ ) from ex
time.sleep(delay)