X-Git-Url: http://git.onelab.eu/?p=nepi.git;a=blobdiff_plain;f=src%2Fnepi%2Futil%2Fsshfuncs.py;h=1899de23ed6002e04bb337c149165b53512da0d2;hp=cfb9908dbf7b427d794f5fae2e2c6c75ab6d2b8f;hb=6285ca51026efb69642eea9dfc7c480e722d84a9;hpb=cb5d027b813a27d7de263653e1a8e0cef5490f0a diff --git a/src/nepi/util/sshfuncs.py b/src/nepi/util/sshfuncs.py index cfb9908d..1899de23 100644 --- a/src/nepi/util/sshfuncs.py +++ b/src/nepi/util/sshfuncs.py @@ -211,12 +211,12 @@ def eintr_retry(func): for i in xrange(0 if retry else 4): try: return func(*p, **kw) - except (select.error, socket.error), args: + except (select.error, socket.error) as args: if args[0] == errno.EINTR: continue else: raise - except OSError, e: + except OSError as e: if e.errno == errno.EINTR: continue else: @@ -342,7 +342,7 @@ def rcopy(source, dest, elif isinstance(source, str) and ':' in source: remspec, path = source.split(':',1) else: - raise ValueError, "Both endpoints cannot be local" + raise ValueError("Both endpoints cannot be local") user,host = remspec.rsplit('@',1) # plain scp @@ -503,7 +503,7 @@ def rspawn(command, pidfile, ) if proc.wait(): - raise RuntimeError, "Failed to set up application on host %s: %s %s" % (host, out,err,) + raise RuntimeError("Failed to set up application on host %s: %s %s" % (host, out,err,)) return ((out, err), proc) @@ -750,7 +750,7 @@ def _retry_rexec(args, time.sleep(t) continue break - except RuntimeError, e: + except RuntimeError as e: msg = " rexec EXCEPTION - TIMEOUT -> %s \n %s" % ( e.args, log_msg ) log(msg, logging.DEBUG, out, err) @@ -816,7 +816,7 @@ def _communicate(proc, input, timeout=None, err_on_timeout=True): try: rlist, wlist, xlist = select.select(read_set, write_set, [], select_timeout) - except select.error,e: + except select.error as e: if e[0] != 4: raise else: @@ -870,7 +870,7 @@ def _communicate(proc, input, timeout=None, err_on_timeout=True): if killed and err_on_timeout: errcode = proc.poll() - raise RuntimeError, ("Operation timed out", errcode, stdout, stderr) + raise RuntimeError("Operation timed out", errcode, stdout, stderr) else: if killed: proc.poll()