Chromium Code Reviews| Index: testing/tools/common.py |
| diff --git a/testing/tools/common.py b/testing/tools/common.py |
| index 1e1d257f48d608eb33845e9877b588442577e118..a0cc946f1ad5377b4629255adaede150f57c45d1 100755 |
| --- a/testing/tools/common.py |
| +++ b/testing/tools/common.py |
| @@ -25,6 +25,24 @@ def RunCommand(cmd): |
| except subprocess.CalledProcessError as e: |
| return e |
| +# RunCommandExtractHashedFiles returns a tuple: (raised_exception, hashed_files) |
|
borenet
2016/12/21 19:47:28
Isn't it more idiomatic just to let the exception
stephana
2016/12/21 21:47:57
I agree, but I wanted the changes to be minimal to
|
| +# It runs the given command. If it fails it will return an exception and None. |
| +# If it succeeds it will return None and the list of processed files extracted |
| +# from the output of the command. It expects lines in this format: |
| +# MD5:<path_to_image_file>:<md5_hash_in_hex> |
| +# The returned hashed_files is a list of (file_path, MD5-hash) pairs. |
| +def RunCommandExtractHashedFiles(cmd): |
| + try: |
| + output = subprocess.check_output(cmd, universal_newlines=True) |
| + ret = [] |
| + for line in output.split('\n'): |
| + line = line.strip() |
| + if line.startswith("MD5:"): |
| + ret.append([x.strip() for x in line.lstrip("MD5:").rsplit(":", 1)]) |
| + return None, ret |
| + except subprocess.CalledProcessError as e: |
| + return e, None |
| + |
| # Adjust Dr. Memory wrapper to have separate log directory for each test |
| # for better error reporting. |
| def DrMemoryWrapper(wrapper, pdf_name): |