From 7960ab5db6e06a25552ec96c1ee4f61c1b69784f Mon Sep 17 00:00:00 2001 From: Matyas Selmeci Date: Mon, 23 Oct 2023 15:49:08 -0500 Subject: [PATCH 1/3] Use correct signature for subprocess.CalledProcessError --- yumconf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yumconf.py b/yumconf.py index 89c42cb..e67e8db 100755 --- a/yumconf.py +++ b/yumconf.py @@ -131,7 +131,10 @@ def repoquery(self, *args): if not retcode: return output else: - raise subprocess.CalledProcessError("repoquery failed") + raise subprocess.CalledProcessError(retcode, + cmd, + output, + "") def install(self, installroot, packages): From d4c07c3d4381276d14938fcc3f97c98240200e70 Mon Sep 17 00:00:00 2001 From: Matyas Selmeci Date: Mon, 23 Oct 2023 15:53:17 -0500 Subject: [PATCH 2/3] Handle multiple lines in "repoquery" output; also don't shell out just to call head(1) --- yumconf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 yumconf.py diff --git a/yumconf.py b/yumconf.py old mode 100755 new mode 100644 index e67e8db..8f5e7d6 --- a/yumconf.py +++ b/yumconf.py @@ -106,8 +106,8 @@ def yum_clean(self): subprocess.call(["yum", "clean", "all"] + args, stdout=fnull) def _get_yum_major_version(self): - proc = subprocess.Popen("yum --version | head -n1", shell=True, stdout=subprocess.PIPE) - output = to_str(proc.communicate()[0]).strip() + proc = subprocess.Popen(["yum", "--version"], stdout=subprocess.PIPE) + output = to_str(proc.communicate()[0]).strip().splitlines()[0] version = output.split(".") try: return int(version[0]) @@ -125,7 +125,7 @@ def repoquery(self, *args): cmd.extend(self.repo_args) cmd.extend(args) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) - output = to_str(proc.communicate()[0]) + output = to_str(proc.communicate()[0]).splitlines()[0] retcode = proc.returncode if not retcode: From 7e8aa097d4368d609f609e1e1bf14a0377b7a411 Mon Sep 17 00:00:00 2001 From: Matyas Selmeci Date: Mon, 23 Oct 2023 16:15:24 -0500 Subject: [PATCH 3/3] Use correct exit code for 'command not found' --- make-client-tarball | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make-client-tarball b/make-client-tarball index c38eb6e..a7a08e5 100755 --- a/make-client-tarball +++ b/make-client-tarball @@ -9,7 +9,7 @@ elif test -x /usr/libexec/platform-python; then python=/usr/libexec/platform-python else echo >&2 "Can't find Python" - exit 255 + exit 127 fi exec "$python" "$(dirname "$0")/make_client_tarball.py" "$@"