os.getenv('GERRIT_SSHPORT'))
- return retry(_clone_gitproject, (giturl, gerritprj, localdir))
+ return retry(_clone_gitproject, giturl, gerritprj, localdir)
from common import runner
+class RuntimeException(Exception):
+ """Local error handler"""
+ pass
+
class Workdir(object):
"""A class which supports with statement"""
def __exit__(self, _type, _value, _tb):
os.chdir(self._cwd)
-def retry(func, opts):
+def retry(func, *opts):
"""This will try to execute one function 3 times(by default) until \
success."""
retry_count = 3
while retry_count > 0:
- if apply(func, opts):
+ if (lambda func, *args: func(*args))(func, *opts):
return True
else:
print '%s failed, retrying...' % func
# Through rsync protocol
if destination.startswith('rsync:'):
- cmd = "rsync -av %s/ %s" %(source, destination)
+ cmd = "rsync -av %s/ %s" % (source, destination)
# Through ssh protocol
elif destination.startswith('ssh:'):
destination = destination.replace("ssh://", "")
- cmd = "scp -r %s/* %s" %(source, destination)
+ cmd = "scp -r %s/* %s" % (source, destination)
# Try to take the destination as local path
else:
- cmd = "mv -v %s/* %s/" %(source, destination)
+ cmd = "mv -v %s/* %s/" % (source, destination)
try:
ret_code = subprocess.call(cmd, shell = True)
except OSError as err: