Pylint for common/utils.py
authorLingchaox Xin <lingchaox.xin@intel.com>
Fri, 14 Jun 2013 02:20:10 +0000 (10:20 +0800)
committerLingchaox Xin <lingchaox.xin@intel.com>
Fri, 14 Jun 2013 02:58:13 +0000 (10:58 +0800)
Replace apply() with the extended call syntax:
function(*args, **keywords).

Fix no RuntimeException found error.

Change-Id: I6dbe96c23e982726d4ac0281cb2075288d5f24b9

common/git.py
common/utils.py

index 0539fa6..e73e8b2 100644 (file)
@@ -196,4 +196,4 @@ def clone_gitproject(gerritprj, localdir, giturl=None):
                                     os.getenv('GERRIT_SSHPORT'))
 
 
-    return retry(_clone_gitproject, (giturl, gerritprj, localdir))
+    return retry(_clone_gitproject, giturl, gerritprj, localdir)
index 2ee51aa..9050af6 100644 (file)
@@ -24,6 +24,10 @@ import subprocess
 
 from common import runner
 
+class RuntimeException(Exception):
+    """Local error handler"""
+    pass
+
 class Workdir(object):
     """A class which supports with statement"""
 
@@ -39,13 +43,13 @@ class Workdir(object):
     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
@@ -100,16 +104,16 @@ def sync(source, destination):
 
     # 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: