Commit 8ad0da1e authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix warnings/errors with newer pylint



To help developing Ganeti on newer distributions, let's try to fix
pylint warnings/errors. I'm using pylint from current Debian wheezy:
pylint 0.25.1, astng 0.23.1, common 0.58.0, and we have 3 things that
needs fixing.

First, a really wide "except", with the silencing in the wrong
place. I'm not sure why this doesn't have "except Exception", so let's
add it. However, pylint still complains about "Catching too general
exception", even though we do want to catch both system and our
exception, so let's add a silence for W0703. It's true that we
shouldn't catch KeyboardInterrupt and friends, but that should be
cleaned up on the master branch.

Second, pylint complains about "redefining name builtin tuple",
because we do some pattern matching in the except blocks in
netutils. This seems to be a false positive, but let's clean the code
around this.

And finally, type inference again goes bad, so let's silence E1103
with its "boolean doesn't have 'get' method".

After this, I can run "make lint", and by extension "make
commit-check" on Debian Wheezy, yay! We might be able to bump our
required pylint versions to something not ancient…
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent fc3f75dd
......@@ -957,9 +957,8 @@ def _RunPostHook(lu, node_name):
hm = lu.proc.BuildHooksManager(lu)
try:
hm.RunPhase(constants.HOOKS_PHASE_POST, nodes=[node_name])
except:
# pylint: disable=W0702
lu.LogWarning("Errors occurred running hooks on %s" % node_name)
except Exception, err: # pylint: disable=W0703
lu.LogWarning("Errors occurred running hooks on %s: %s" % (node_name, err))
 
 
def _CheckOutputFields(static, dynamic, selected):
......
#
#
# Copyright (C) 2010 Google Inc.
# Copyright (C) 2010, 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -280,8 +280,8 @@ def TcpPing(target, port, timeout=10, live_port_needed=False, source=None):
if source is not None:
try:
sock.bind((source, 0))
except socket.error, (errcode, _):
if errcode == errno.EADDRNOTAVAIL:
except socket.error, err:
if err[0] == errno.EADDRNOTAVAIL:
success = False
sock.settimeout(timeout)
......@@ -292,8 +292,8 @@ def TcpPing(target, port, timeout=10, live_port_needed=False, source=None):
success = True
except socket.timeout:
success = False
except socket.error, (errcode, _):
success = (not live_port_needed) and (errcode == errno.ECONNREFUSED)
except socket.error, err:
success = (not live_port_needed) and (err[0] == errno.ECONNREFUSED)
return success
......
......@@ -44,7 +44,7 @@ import qa_tags
import qa_utils
from ganeti import utils
from ganeti import rapi
from ganeti import rapi # pylint: disable=W0611
from ganeti import constants
import ganeti.rapi.client # pylint: disable=W0611
......
......@@ -80,7 +80,7 @@ def Validate():
def get(name, default=None):
return cfg.get(name, default)
return cfg.get(name, default) # pylint: disable=E1103
class Either:
......@@ -149,7 +149,7 @@ def TestEnabled(tests, _cfg=None):
_cfg = cfg
# Get settings for all tests
cfg_tests = _cfg.get("tests", {})
cfg_tests = _cfg.get("tests", {}) # pylint: disable=E1103
# Get default setting
default = cfg_tests.get("default", True)
......@@ -162,7 +162,7 @@ def GetInstanceCheckScript():
"""Returns path to instance check script or C{None}.
"""
return cfg.get(_INSTANCE_CHECK_KEY, None)
return cfg.get(_INSTANCE_CHECK_KEY, None) # pylint: disable=E1103
def GetEnabledHypervisors():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment