Index: lib/cros_build_lib.py |
diff --git a/lib/cros_build_lib.py b/lib/cros_build_lib.py |
index 7b9b00da8664eb816448eb67689f985bbce575e4..a0cd73c6edaac26c2324c7af158a5c00d7bf762d 100644 |
--- a/lib/cros_build_lib.py |
+++ b/lib/cros_build_lib.py |
@@ -34,6 +34,7 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None, |
stdout = None |
stderr = None |
stdin = None |
+ output = '' |
# Modify defaults based on parameters. |
if redirect_stdout: stdout = subprocess.PIPE |
@@ -45,15 +46,21 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None, |
if print_cmd: |
Info('RunCommand: %s' % ' '.join(cmd)) |
- proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin, |
- stdout=stdout, stderr=stderr) |
- (output, error) = proc.communicate(input) |
- if exit_code: |
- return proc.returncode |
- |
- if not error_ok and proc.returncode: |
- raise Exception('Command "%s" failed.\n' % (' '.join(cmd)) + |
- (error_message or error or output or '')) |
+ try: |
+ proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin, |
+ stdout=stdout, stderr=stderr) |
+ (output, error) = proc.communicate(input) |
+ if exit_code: |
+ return proc.returncode |
+ |
+ if not error_ok and proc.returncode: |
+ raise Exception('Command "%s" failed.\n' % (' '.join(cmd)) + |
+ (error_message or error or output or '')) |
+ except Exception,e: |
petkov
2010/08/31 16:27:19
space after ,
|
+ if not error_ok: |
+ raise |
+ else: |
+ Warning(str(e)) |
return output |