| Index: appengine/findit/util_scripts/script_util.py
|
| diff --git a/appengine/findit/util_scripts/script_util.py b/appengine/findit/util_scripts/script_util.py
|
| index 1d9846d437f3a7cb4731b5c728d05b11631c2e02..dc4da5cf06aa4618ecacfb9279df174e69ab996d 100644
|
| --- a/appengine/findit/util_scripts/script_util.py
|
| +++ b/appengine/findit/util_scripts/script_util.py
|
| @@ -4,11 +4,13 @@
|
|
|
| """This module contains util functions that local scripts can use."""
|
|
|
| +import logging
|
| import os
|
| +import subprocess
|
| import sys
|
|
|
|
|
| -def SetUpSystemPaths():
|
| +def SetUpSystemPaths(): # pragma: no cover
|
| """Sets system paths so as to import modules in findit, third_party and
|
| appengine."""
|
| findit_root_dir = os.path.join(os.path.dirname(__file__), os.path.pardir)
|
| @@ -25,3 +27,24 @@ def SetUpSystemPaths():
|
|
|
| # Add Findit root dir to sys.path so that modules in Findit is available.
|
| sys.path.insert(1, findit_root_dir)
|
| +
|
| +
|
| +# 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
|
| +
|
| + return stdoutdata
|
|
|