blob: 9a8b5e2e5a953bcc51acbd6f226f23fcd6236be4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import subprocess
import time
def run(args, test=False, retry=0):
print " ".join(args)
if test:
return
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, retry=retry)
|