Chromium Code Reviews| Index: appengine/findit/lib/gitiles/repo_util.py |
| diff --git a/appengine/findit/lib/gitiles/repo_util.py b/appengine/findit/lib/gitiles/repo_util.py |
| index 790a6f796a45259a9e985d14aa3c860c5ca3c1e0..9bc811fe38069ca849419c2428d58890ff5848e4 100644 |
| --- a/appengine/findit/lib/gitiles/repo_util.py |
| +++ b/appengine/findit/lib/gitiles/repo_util.py |
| @@ -2,7 +2,11 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import json |
| +import logging |
| import re |
| +import subprocess |
| +import urllib2 |
| CODE_REVIEW_URL_PATTERN = re.compile( |
| '^(?:Review URL|Review-Url): (.*\d+).*$', re.IGNORECASE) |
| @@ -69,3 +73,24 @@ def GetRevertedRevision(message): |
| reverted_revision_match = REVERTED_REVISION_PATTERN.match(line) |
| if reverted_revision_match: |
| return reverted_revision_match.group(1) |
| + |
| + |
| +# TODO(katesonia): Add local cache for this function. |
| +def GetCommandOutput(command): |
| + """Gets the output stream of executable command. |
| + |
| + Args: |
| + command (str): Command to execute to get output. |
| + |
| + Return: |
| + Output steam of the command. |
| + """ |
| + p = subprocess.Popen( |
| + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) |
| + stdoutdata, stderrdata = p.communicate() |
| + |
| + if p.returncode != 0: |
| + logging.error('Error running command %s: %s', command, stderrdata) |
| + return None |
|
wrengr
2016/11/01 20:26:53
You probably want to throw an exception packaging
Sharu Jiang
2016/11/05 01:18:15
Crashing the program working for local testing, bu
|
| + |
| + return stdoutdata |