diff options
author | James Tunnicliffe <james.tunnicliffe@linaro.org> | 2011-07-21 13:52:11 +0100 |
---|---|---|
committer | James Tunnicliffe <james.tunnicliffe@linaro.org> | 2011-07-21 13:52:11 +0100 |
commit | 6da1def49ed46b9ce815a168352b8d9a46aaf2a1 (patch) | |
tree | 1df106b0eaaeebb945df584d94e6df9be3f83a9c /linaro_image_tools/utils.py | |
parent | d95d1eea51a5aa2c488dcda1a49ce8b73dd81aad (diff) |
Added communicate function to cmd_runner that will both throw an exception if the function it is communicating with exits with a non-zero exit code and also returns stdout and stderr in the exception object.
Diffstat (limited to 'linaro_image_tools/utils.py')
-rw-r--r-- | linaro_image_tools/utils.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/linaro_image_tools/utils.py b/linaro_image_tools/utils.py index c1a6f96..048a9b7 100644 --- a/linaro_image_tools/utils.py +++ b/linaro_image_tools/utils.py @@ -57,11 +57,15 @@ def verify_file_integrity(sig_file_list): else: sha_cwd = os.path.dirname(hash_file) - sha1sums_out, _ = subprocess.Popen(['sha1sum', '-c', hash_file], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - cwd=sha_cwd - ).communicate() + try: + sha1sums_out, _ = cmd_runner.Popen( + ['sha1sum', '-c', hash_file], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + cwd=sha_cwd + ).communicate() + except cmd_runner.SubcommandNonZeroReturnValue as inst: + sha1sums_out = inst.stdout for line in sha1sums_out.splitlines(): sha1_check = re.search(r'^(.*):\s+OK', line) |