From 8ef72883cb828d29c085bbbf736dbe28b1acd33c Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Tue, 3 Oct 2023 11:04:43 +0100 Subject: [PATCH] Fix output redirection issues Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/utility/utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index bcb512f88a43..a52c5b1c2b58 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -4451,7 +4451,11 @@ def get_oadp_version(): for csv in csv_list: if "oadp-operator" in csv: # extract version string - cmd = f"oc get csv/{csv} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide | awk {{'print $4'}}" - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) - out = p.communicate() - return out[0].splitlines[1].decode() + cmd = f"oc get csv/{csv} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide " + awk_cmd = "awk {{'print $4'}}" + p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) + outbuf = subprocess.Popen( + shlex.split(awk_cmd), stdin=p.stdout, stdout=subprocess.PIPE + ) + out = outbuf.communicate() + return out[0].splitlines()[1].decode()