Skip to content

Commit 4569af7

Browse files
committed
Bugfix: Optional parameter use in run_command_output & legacy return_code
1 parent bfd698e commit 4569af7

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/core/src/bootstrap/EnvLayer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ def get_env_var(self, var_name, raise_if_not_success=False):
135135
print("Error occurred while getting environment variable [Variable={0}][Exception={1}]".format(str(var_name), repr(error)))
136136
if raise_if_not_success:
137137
raise
138+
return None
138139

139-
def run_command_output(self, cmd, no_output, chk_err=True):
140+
def run_command_output(self, cmd, no_output=False, chk_err=True):
140141
# type: (str, bool, bool) -> (int, any)
141142
""" Wrapper for subprocess.check_output. Execute 'cmd'. Returns return code and STDOUT, trapping expected exceptions. Reports exceptions to Error if chk_err parameter is True """
142143

@@ -185,7 +186,7 @@ def __str__(self):
185186
output = subprocess.check_output(no_output, cmd, stderr=subprocess.STDOUT, shell=True)
186187
except subprocess.CalledProcessError as e:
187188
if chk_err:
188-
print("Error: CalledProcessError. [Code={0}][Command={1}][Result={2}]".format(str(e.returncode), e.cmd, self.__convert_process_output_to_ascii(e.output[:-1])), file=sys.stdout)
189+
print("Error: CalledProcessError. [Code={0}][Command={1}][Result={2}]".format(str(e.return_code), e.cmd, self.__convert_process_output_to_ascii(e.output[:-1])), file=sys.stdout)
189190
if no_output:
190191
return e.return_code, None
191192
else:

src/extension/src/EnvLayer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __str__(self):
9797
no_output, cmd, stderr=subprocess.STDOUT, shell=True)
9898
except subprocess.CalledProcessError as e:
9999
if chk_err:
100-
print("Error: CalledProcessError. Error Code is: " + str(e.returncode), file=sys.stdout)
100+
print("Error: CalledProcessError. Error Code is: " + str(e.return_code), file=sys.stdout)
101101
print("Error: CalledProcessError. Command string was: " + e.cmd, file=sys.stdout)
102102
print("Error: CalledProcessError. Command result was: " + self.__convert_process_output_to_ascii(e.output[:-1]), file=sys.stdout)
103103
if no_output:

0 commit comments

Comments
 (0)