Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/command.py
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-11-20 09:06:23 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-11-20 09:06:23 (GMT)
commitab7dc2d7b0e2964eafc387f3dd73e52afd0332de (patch)
tree7bdcef02b8def4856c391b0fdc02c3ced48c6b61 /devbot/command.py
parent3aee5544e9166e7ebc000d6be2c2340e25c7a720 (diff)
Retry git commands that requires the network
Diffstat (limited to 'devbot/command.py')
-rw-r--r--devbot/command.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/devbot/command.py b/devbot/command.py
index 9a39a06..9a8b5e2 100644
--- a/devbot/command.py
+++ b/devbot/command.py
@@ -1,12 +1,26 @@
import subprocess
+import time
-def run(args, test=False):
+def run(args, test=False, retry=0):
print " ".join(args)
- if not test:
- subprocess.check_call(args)
+ if test:
+ return
-def run_with_sudo(args, test=False):
+ tries = 0
+ while tries < retry + 1:
+ try:
+ tries = tries + 1
+ subprocess.check_call(args)
+ return
+ except subprocess.CalledProcessError, e:
+ if tries < retry + 1:
+ print "Retrying (attempt %d) in 1 minute" % tries
+ time.sleep(60)
+ else:
+ raise e
+
+def run_with_sudo(args, test=False, retry=0):
args_with_sudo = ["sudo"]
args_with_sudo.extend(args)
- run(args_with_sudo, test=test)
+ run(args_with_sudo, test=test, retry=retry)