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

Unified Diff: lib/cros_build_lib.py

Issue 4864001: Change _ArchiveTestResults to upload to Google Storage (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Fix code review feedbacks Created 10 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
« bin/cbuildbot.py ('K') | « 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 509871c6eedbe06ad9b9e160930e4eae4a3f2fa5..a07606c6447024b109668f3f34ee984e9febe03d 100644
--- a/lib/cros_build_lib.py
+++ b/lib/cros_build_lib.py
@@ -76,6 +76,37 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
return output
+def RunCommandWithRetries(cmd, num_retries=5):
+ """Runs a shell command with retries
+
+ Runs a shell command. In case of failure, this function will retry the
+ command up to num_retries times.
+
+ Arguments:
+ cmd: Array of commands/args to execute
+ num_retries: The number of retries to perform before dying
+
+ Returns:
+ The stdout output of the command.
+
+ Raises:
+ Exception: Raises generic exception on error with optional error_message.
+ """
+ output = ''
+
+ for i in range(num_retries):
+ try:
+ output = RunCommand(cmd)
+ break
+ except Exception, e:
+ if (i < num_retries - 1):
+ Warning('Retrying command: %r' % cmd)
+ else:
+ raise
+
+ return output
+
+
class Color(object):
"""Conditionally wraps text in ANSI color escape sequences."""
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
« bin/cbuildbot.py ('K') | « bin/cbuildbot.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698