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

Unified Diff: runtime/tools/utils.py

Issue 10916021: Fix android_finder.py (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use startswith Created 8 years, 4 months 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 | « runtime/tools/android_finder.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/tools/utils.py
diff --git a/runtime/tools/utils.py b/runtime/tools/utils.py
index 72312c59302352770a3679d3d7dae88ff22881f9..242e6d337ed69777b1b3a0389538c6dbdfa82b63 100644
--- a/runtime/tools/utils.py
+++ b/runtime/tools/utils.py
@@ -167,12 +167,14 @@ def RunCommand(command, input=None, pollFn=None, outStream=None, errStream=None,
returns a non-zero exit code.
Returns: the output of the subprocess.
- Raises an exception if the subprocess returns an error code.
+ Exceptions:
+ Raises Error if the subprocess returns an error code.
+ Raises ValueError if called with invalid arguments.
"""
if verbose:
sys.stderr.write("command %s\n" % command)
stdin = None
- if input is not None:
+ if input:
stdin = subprocess.PIPE
try:
process = subprocess.Popen(args=command,
@@ -180,12 +182,12 @@ def RunCommand(command, input=None, pollFn=None, outStream=None, errStream=None,
bufsize=1,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- except Exception as e:
+ except OSError as e:
if not isinstance(command, basestring):
command = ' '.join(command)
if printErrorInfo:
sys.stderr.write("Command failed: '%s'\n" % command)
- raise e
+ raise Error(e)
def StartThread(out):
queue = Queue.Queue()
@@ -212,7 +214,7 @@ def RunCommand(command, input=None, pollFn=None, outStream=None, errStream=None,
outBuf = StringIO.StringIO()
errorBuf = StringIO.StringIO()
- if input != None:
+ if input:
process.stdin.write(input)
while True:
returncode = process.poll()
@@ -232,7 +234,7 @@ def RunCommand(command, input=None, pollFn=None, outStream=None, errStream=None,
out = outBuf.getvalue();
error = errorBuf.getvalue();
- if returncode != 0:
+ if returncode:
if not isinstance(command, basestring):
command = ' '.join(command)
if printErrorInfo:
@@ -240,7 +242,7 @@ def RunCommand(command, input=None, pollFn=None, outStream=None, errStream=None,
sys.stderr.write(" stdout: '%s'\n" % out)
sys.stderr.write(" stderr: '%s'\n" % error)
sys.stderr.write(" returncode: %d\n" % returncode)
- raise Exception("Command failed: %s" % command)
+ raise Error("Command failed: %s" % command)
if debug:
sys.stderr.write("output: %s\n" % out)
return out
@@ -253,6 +255,10 @@ def Main(argv):
print "IsWindows() -> ", IsWindows()
+class Error(Exception):
+ pass
+
+
if __name__ == "__main__":
import sys
Main(sys.argv)
« no previous file with comments | « runtime/tools/android_finder.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698