Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
Fran-Rg committed Jan 19, 2024
1 parent c76586f commit 486b4eb
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 486b4eb

Please sign in to comment.