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

Unified Diff: gclient_utils.py

Issue 502078: Remove trychange.RunCommand and replace it by gclient_utils.CheckCall. (Closed)
Patch Set: Created 11 years 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
« no previous file with comments | « no previous file | tests/gclient_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index 3a6438d1c0226dd1bf8d1d288e574dbdef0ed399..81379c30e886d110b9aaf23bda819cf6bf72dcbe 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -25,6 +25,30 @@ import xml.dom.minidom
import xml.parsers.expat
+class CheckCallError(OSError):
+ """CheckCall() returned non-0."""
+ def __init__(self, command, cwd, retcode, stdout):
+ OSError.__init__(self, command, cwd, retcode, stdout)
+ self.command = command
+ self.cwd = cwd
+ self.retcode = retcode
+ self.stdout = stdout
+
+
+def CheckCall(command, cwd=None):
+ """Like subprocess.check_call() but returns stdout.
+
+ Works on python 2.4
+ """
+ process = subprocess.Popen(command, cwd=cwd,
+ shell=sys.platform.startswith('win'),
+ stdout=subprocess.PIPE)
+ output = process.communicate()[0]
+ if process.retcode:
+ raise CheckCallError(command, cwd, process.retcode, output)
+ return output
+
+
def SplitUrlRevision(url):
"""Splits url and returns a two-tuple: url, rev"""
if url.startswith('ssh:'):
« no previous file with comments | « no previous file | tests/gclient_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698