From 486b4ebb4f605397f787cb8cd5f18426c043964f Mon Sep 17 00:00:00 2001 From: Francois Regnoult Date: Fri, 19 Jan 2024 11:16:27 +0000 Subject: [PATCH] Cleanup code --- package.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/package.py b/package.py index 42bbe919..be06a9f8 100644 --- a/package.py +++ b/package.py @@ -914,21 +914,26 @@ def execute(self, build_plan, zip_stream, query): # XXX: timestamp=0 - what actually do with it? zs.write_dirs(rd, prefix=prefix, timestamp=0) elif cmd == "sh": - r, w = os.pipe() - side_ch = os.fdopen(r) path, script = action[1:] - script = "set -e\n{}\nset +e;pwd >&{}".format(script, w) - p = subprocess.Popen(script, shell=True, cwd=path, pass_fds=(w,)) - os.close(w) - sh_work_dir = side_ch.read().strip() + script = "set -e\n{}".format(script) + p = subprocess.Popen( + script, + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=path, + ) + p.wait() - log.info("WD: %s", sh_work_dir) - side_ch.close() + call_stdout, call_stderr = p.communicate() exit_code = p.returncode + log.info("exit_code: %s", exit_code) if exit_code != 0: raise RuntimeError( - "Script did not run successfully, exit code {}".format( - exit_code + "Script did not run successfully, exit code {}: {} - {}".format( + exit_code, + call_stdout.decode("utf-8").strip(), + call_stderr.decode("utf-8").strip(), ) ) patterns = action[1]