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

Unified Diff: lib/cros_build_lib.py

Issue 3255004: Fix cleanup so we don't have to clobber as much when failures occur (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Fix ws Created 10 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 | « bin/cbuildbot.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « bin/cbuildbot.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698