Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1534)

Unified Diff: appengine/findit/util_scripts/script_util.py

Issue 2432113002: [Findit] Add local_git_repository (Closed)
Patch Set: Rebase. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698