From e3dd94d65c88f6b7041e1f778420d731d3047cce Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Thu, 29 May 2014 23:57:26 +0200 Subject: [PATCH] Use except x as y instead of except x, y According to https://docs.python.org/3/howto/pyporting.html the syntax changed in Python 3.x. The new syntax is usable with Python >= 2.6 and should be preferred to be compatible with Python3. Enabled hacking check H231. Change-Id: Ide60f971493440311f1dcc594e33d536beb925e5 --- nodepool/nodepool.py | 4 ++-- nodepool/nodeutils.py | 4 ++-- tox.ini | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nodepool/nodepool.py b/nodepool/nodepool.py index 88746d734..8bf904f0a 100644 --- a/nodepool/nodepool.py +++ b/nodepool/nodepool.py @@ -330,7 +330,7 @@ class NodeLauncher(threading.Thread): dt = self.launchNode(session) failed = False statsd_key = 'ready' - except Exception, e: + except Exception as e: self.log.exception("%s launching node id: %s " "in provider: %s error:" % (e.__class__.__name__, @@ -571,7 +571,7 @@ class SubNodeLauncher(threading.Thread): dt = self.launchSubNode(session) failed = False statsd_key = 'ready' - except Exception, e: + except Exception as e: self.log.exception("%s launching subnode id: %s " "for node id: %s in provider: %s error:" % (e.__class__.__name__, self.subnode_id, diff --git a/nodepool/nodeutils.py b/nodepool/nodeutils.py index 9762af3eb..2434f6a6f 100644 --- a/nodepool/nodeutils.py +++ b/nodepool/nodeutils.py @@ -47,11 +47,11 @@ def ssh_connect(ip, username, connect_kwargs={}, timeout=60): try: client = SSHClient(ip, username, **connect_kwargs) break - except paramiko.AuthenticationException, e: + except paramiko.AuthenticationException as e: # This covers the case where the cloud user is created # after sshd is up (Fedora for example) log.info('Password auth exception. Try number %i...' % count) - except socket.error, e: + except socket.error as e: if e[0] not in [errno.ECONNREFUSED, errno.EHOSTUNREACH]: log.exception('Exception while testing ssh access:') diff --git a/tox.ini b/tox.ini index 523c243d6..7da57c418 100644 --- a/tox.ini +++ b/tox.ini @@ -27,5 +27,6 @@ commands = {posargs} [flake8] ignore = E123,E125,H +select = H231 show-source = True exclude = .venv,.tox,dist,doc,build,*.egg