Commit b459a848 authored by Andrea Spadaccini's avatar Andrea Spadaccini Committed by Iustin Pop

DeprecationWarning fixes for pylint

In version 0.21, pylint unified all the disable-* (and enable-*)
directives to disable (resp. enable). This leads to a lot of
DeprecationWarning being emitted even if one uses the recommended
version of pylint (0.21.1, as stated in devnotes.rst).

This commit changes all the disable-msg directives to disable.
Signed-off-by: default avatarAndrea Spadaccini <spadaccio@google.com>
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 2c094917
......@@ -23,7 +23,7 @@
"""
# pylint: disable-msg=C0103
# pylint: disable=C0103
# [C0103] Invalid name build-bash-completion
import os
......@@ -241,7 +241,7 @@ class CompletionWriter:
for opt in opts:
# While documented, these variables aren't seen as public attributes by
# pylint. pylint: disable-msg=W0212
# pylint. pylint: disable=W0212
opt.all_names = sorted(opt._short_opts + opt._long_opts)
def _FindFirstArgument(self, sw):
......
......@@ -23,7 +23,7 @@
"""
# pylint: disable-msg=C0103
# pylint: disable=C0103
# C0103: Invalid name import-export
import errno
......@@ -353,7 +353,7 @@ def ParseOptions():
@return: Arguments to program
"""
global options # pylint: disable-msg=W0603
global options # pylint: disable=W0603
parser = optparse.OptionParser(usage=("%%prog <status-file> {%s|%s}" %
(constants.IEM_IMPORT,
......@@ -587,7 +587,7 @@ def main():
errmsg = "Exited with status %s" % (child.returncode, )
status_file.SetExitStatus(child.returncode, errmsg)
except Exception, err: # pylint: disable-msg=W0703
except Exception, err: # pylint: disable=W0703
logging.exception("Unhandled error occurred")
status_file.SetExitStatus(constants.EXIT_FAILURE,
"Unhandled error occurred: %s" % (err, ))
......
......@@ -26,7 +26,7 @@ import asyncore
import logging
try:
# pylint: disable-msg=E0611
# pylint: disable=E0611
from pyinotify import pyinotify
except ImportError:
import pyinotify
......@@ -42,7 +42,7 @@ class AsyncNotifier(asyncore.file_dispatcher):
"""An asyncore dispatcher for inotify events.
"""
# pylint: disable-msg=W0622,W0212
# pylint: disable=W0622,W0212
def __init__(self, watch_manager, default_proc_fun=None, map=None):
"""Initializes this class.
......@@ -90,7 +90,7 @@ class FileEventHandlerBase(pyinotify.ProcessEvent):
@param watch_manager: inotify watch manager
"""
# pylint: disable-msg=W0231
# pylint: disable=W0231
# no need to call the parent's constructor
self.watch_manager = watch_manager
......@@ -168,7 +168,7 @@ class SingleFileEventHandler(FileEventHandlerBase):
if self._watch_handle is not None and self.RemoveWatch(self._watch_handle):
self._watch_handle = None
# pylint: disable-msg=C0103
# pylint: disable=C0103
# this overrides a method in pyinotify.ProcessEvent
def process_IN_IGNORED(self, event):
# Since we monitor a single file rather than the directory it resides in,
......@@ -182,7 +182,7 @@ class SingleFileEventHandler(FileEventHandlerBase):
self._watch_handle = None
self._callback(False)
# pylint: disable-msg=C0103
# pylint: disable=C0103
# this overrides a method in pyinotify.ProcessEvent
def process_IN_MODIFY(self, event):
# This gets called when the monitored file is modified. Note that this
......
......@@ -28,7 +28,7 @@
"""
# pylint: disable-msg=E1103
# pylint: disable=E1103
# E1103: %s %r has no %r member (but some types could not be
# inferred), because the _TryOSFromDisk returns either (True, os_obj)
......@@ -412,7 +412,7 @@ def LeaveCluster(modify_ssh_setup):
utils.RemoveFile(constants.CONFD_HMAC_KEY)
utils.RemoveFile(constants.RAPI_CERT_FILE)
utils.RemoveFile(constants.NODED_CERT_FILE)
except: # pylint: disable-msg=W0702
except: # pylint: disable=W0702
logging.exception("Error while removing cluster secrets")
result = utils.RunCmd([constants.DAEMON_UTIL, "stop", constants.CONFD])
......@@ -1340,7 +1340,7 @@ def BlockdevCreate(disk, size, owner, on_primary, info):
"""
# TODO: remove the obsolete "size" argument
# pylint: disable-msg=W0613
# pylint: disable=W0613
clist = []
if disk.children:
for child in disk.children:
......@@ -1352,7 +1352,7 @@ def BlockdevCreate(disk, size, owner, on_primary, info):
# we need the children open in case the device itself has to
# be assembled
try:
# pylint: disable-msg=E1103
# pylint: disable=E1103
crdev.Open()
except errors.BlockDeviceError, err:
_Fail("Can't make child '%s' read-write: %s", child, err)
......@@ -1568,7 +1568,7 @@ def BlockdevAssemble(disk, owner, as_primary, idx):
try:
result = _RecursiveAssembleBD(disk, owner, as_primary)
if isinstance(result, bdev.BlockDev):
# pylint: disable-msg=E1103
# pylint: disable=E1103
result = result.dev_path
if as_primary:
_SymlinkBlockDev(owner, result, idx)
......@@ -3322,7 +3322,7 @@ def PowercycleNode(hypervisor_type):
# ensure the child is running on ram
try:
utils.Mlockall()
except Exception: # pylint: disable-msg=W0703
except Exception: # pylint: disable=W0703
pass
time.sleep(5)
hyper.PowercycleNode()
......@@ -3347,7 +3347,7 @@ class HooksRunner(object):
hooks_base_dir = constants.HOOKS_BASE_DIR
# yeah, _BASE_DIR is not valid for attributes, we use it like a
# constant
self._BASE_DIR = hooks_base_dir # pylint: disable-msg=C0103
self._BASE_DIR = hooks_base_dir # pylint: disable=C0103
def RunHooks(self, hpath, phase, env):
"""Run the scripts in the hooks directory.
......
......@@ -889,7 +889,7 @@ class DRBD8Status(object):
self.est_time = None
class BaseDRBD(BlockDev): # pylint: disable-msg=W0223
class BaseDRBD(BlockDev): # pylint: disable=W0223
"""Base DRBD class.
This class contains a few bits of common functionality between the
......@@ -1765,7 +1765,7 @@ class DRBD8(BaseDRBD):
"""
# TODO: Rewrite to not use a for loop just because there is 'break'
# pylint: disable-msg=W0631
# pylint: disable=W0631
net_data = (self._lhost, self._lport, self._rhost, self._rport)
for minor in (self._aminor,):
info = self._GetDevInfo(self._GetShowData(minor))
......
......@@ -242,7 +242,7 @@ def _InitFileStorage(file_storage_dir):
return file_storage_dir
def InitCluster(cluster_name, mac_prefix, # pylint: disable-msg=R0913
def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913
master_netdev, file_storage_dir, shared_file_storage_dir,
candidate_pool_size, secondary_ip=None, vg_name=None,
beparams=None, nicparams=None, ndparams=None, hvparams=None,
......
......@@ -42,7 +42,7 @@ from ganeti import opcodes
from ganeti import ht
from ganeti import rapi
import ganeti.rapi.rlib2 # pylint: disable-msg=W0611
import ganeti.rapi.rlib2 # pylint: disable=W0611
COMMON_PARAM_NAMES = map(compat.fst, opcodes.OpCode.OP_PARAMS)
......@@ -213,7 +213,7 @@ def PythonEvalRole(role, rawtext, text, lineno, inliner,
The expression's result is included as a literal.
"""
# pylint: disable-msg=W0102,W0613,W0142
# pylint: disable=W0102,W0613,W0142
# W0102: Dangerous default value as argument
# W0142: Used * or ** magic
# W0613: Unused argument
......@@ -222,7 +222,7 @@ def PythonEvalRole(role, rawtext, text, lineno, inliner,
try:
result = eval(code, EVAL_NS)
except Exception, err: # pylint: disable-msg=W0703
except Exception, err: # pylint: disable=W0703
msg = inliner.reporter.error("Failed to evaluate %r: %s" % (code, err),
line=lineno)
return ([inliner.problematic(rawtext, rawtext, msg)], [msg])
......
......@@ -259,7 +259,7 @@ _PRIONAME_TO_VALUE = dict(_PRIORITY_NAMES)
class _Argument:
def __init__(self, min=0, max=None): # pylint: disable-msg=W0622
def __init__(self, min=0, max=None): # pylint: disable=W0622
self.min = min
self.max = max
......@@ -274,7 +274,7 @@ class ArgSuggest(_Argument):
Value can be any of the ones passed to the constructor.
"""
# pylint: disable-msg=W0622
# pylint: disable=W0622
def __init__(self, min=0, max=None, choices=None):
_Argument.__init__(self, min=min, max=max)
self.choices = choices
......@@ -462,7 +462,7 @@ def RemoveTags(opts, args):
SubmitOpCode(op, opts=opts)
def check_unit(option, opt, value): # pylint: disable-msg=W0613
def check_unit(option, opt, value): # pylint: disable=W0613
"""OptParsers custom converter for units.
"""
......@@ -509,7 +509,7 @@ def _SplitKeyVal(opt, data):
return kv_dict
def check_ident_key_val(option, opt, value): # pylint: disable-msg=W0613
def check_ident_key_val(option, opt, value): # pylint: disable=W0613
"""Custom parser for ident:key=val,key=val options.
This will store the parsed values as a tuple (ident, {key: val}). As such,
......@@ -537,7 +537,7 @@ def check_ident_key_val(option, opt, value): # pylint: disable-msg=W0613
return retval
def check_key_val(option, opt, value): # pylint: disable-msg=W0613
def check_key_val(option, opt, value): # pylint: disable=W0613
"""Custom parser class for key=val,key=val options.
This will store the parsed values as a dict {key: val}.
......@@ -546,7 +546,7 @@ def check_key_val(option, opt, value): # pylint: disable-msg=W0613
return _SplitKeyVal(opt, value)
def check_bool(option, opt, value): # pylint: disable-msg=W0613
def check_bool(option, opt, value): # pylint: disable=W0613
"""Custom parser for yes/no options.
This will store the parsed value as either True or False.
......@@ -2363,8 +2363,8 @@ def GenerateTable(headers, fields, separator, data,
if unitfields is None:
unitfields = []
numfields = utils.FieldSet(*numfields) # pylint: disable-msg=W0142
unitfields = utils.FieldSet(*unitfields) # pylint: disable-msg=W0142
numfields = utils.FieldSet(*numfields) # pylint: disable=W0142
unitfields = utils.FieldSet(*unitfields) # pylint: disable=W0142
format_fields = []
for field in fields:
......
......@@ -20,7 +20,7 @@
"""Backup related commands"""
# pylint: disable-msg=W0401,W0613,W0614,C0103
# pylint: disable=W0401,W0613,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0613: Unused argument, since all functions follow the same API
# W0614: Unused import %s from wildcard import (since we need cli)
......
......@@ -20,7 +20,7 @@
"""Cluster related commands"""
# pylint: disable-msg=W0401,W0613,W0614,C0103
# pylint: disable=W0401,W0613,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0613: Unused argument, since all functions follow the same API
# W0614: Unused import %s from wildcard import (since we need cli)
......@@ -622,7 +622,7 @@ def MasterPing(opts, args):
cl = GetClient()
cl.QueryClusterInfo()
return 0
except Exception: # pylint: disable-msg=W0703
except Exception: # pylint: disable=W0703
return 1
......@@ -685,14 +685,14 @@ def _RenewCrypto(new_cluster_cert, new_rapi_cert, rapi_cert_filename,
OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM,
rapi_cert_pem)
except Exception, err: # pylint: disable-msg=W0703
except Exception, err: # pylint: disable=W0703
ToStderr("Can't load new RAPI certificate from %s: %s" %
(rapi_cert_filename, str(err)))
return 1
try:
OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, rapi_cert_pem)
except Exception, err: # pylint: disable-msg=W0703
except Exception, err: # pylint: disable=W0703
ToStderr("Can't load new RAPI private key from %s: %s" %
(rapi_cert_filename, str(err)))
return 1
......@@ -703,7 +703,7 @@ def _RenewCrypto(new_cluster_cert, new_rapi_cert, rapi_cert_filename,
if cds_filename:
try:
cds = utils.ReadFile(cds_filename)
except Exception, err: # pylint: disable-msg=W0703
except Exception, err: # pylint: disable=W0703
ToStderr("Can't load new cluster domain secret from %s: %s" %
(cds_filename, str(err)))
return 1
......
......@@ -20,7 +20,7 @@
"""Debugging commands"""
# pylint: disable-msg=W0401,W0614,C0103
# pylint: disable=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-backup
......@@ -90,7 +90,7 @@ def GenericOpCodes(opts, args):
ToStdout("Loading...")
for job_idx in range(opts.rep_job):
for fname in args:
# pylint: disable-msg=W0142
# pylint: disable=W0142
op_data = simplejson.loads(utils.ReadFile(fname))
op_list = [opcodes.OpCode.LoadOpCode(val) for val in op_data]
op_list = op_list * opts.rep_op
......@@ -564,7 +564,7 @@ def TestJobqueue(opts, _):
return 0
def ListLocks(opts, args): # pylint: disable-msg=W0613
def ListLocks(opts, args): # pylint: disable=W0613
"""List all locks.
@param opts: the command line options selected by the user
......
......@@ -20,7 +20,7 @@
"""Node group related commands"""
# pylint: disable-msg=W0401,W0614
# pylint: disable=W0401,W0614
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
......
......@@ -20,7 +20,7 @@
"""Instance related commands"""
# pylint: disable-msg=W0401,W0614,C0103
# pylint: disable=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-instance
......@@ -87,7 +87,7 @@ def _ExpandMultiNames(mode, names, client=None):
@raise errors.OpPrereqError: for invalid input parameters
"""
# pylint: disable-msg=W0142
# pylint: disable=W0142
if client is None:
client = GetClient()
......@@ -322,7 +322,7 @@ def BatchCreate(opts, args):
json_filename = args[0]
try:
instance_data = simplejson.loads(utils.ReadFile(json_filename))
except Exception, err: # pylint: disable-msg=W0703
except Exception, err: # pylint: disable=W0703
ToStderr("Can't parse the instance definition file: %s" % str(err))
return 1
......@@ -335,7 +335,7 @@ def BatchCreate(opts, args):
# Iterate over the instances and do:
# * Populate the specs with default value
# * Validate the instance specs
i_names = utils.NiceSort(instance_data.keys()) # pylint: disable-msg=E1103
i_names = utils.NiceSort(instance_data.keys()) # pylint: disable=E1103
for name in i_names:
specs = instance_data[name]
specs = _PopulateWithDefaults(specs)
......
......@@ -20,7 +20,7 @@
"""Job related commands"""
# pylint: disable-msg=W0401,W0613,W0614,C0103
# pylint: disable=W0401,W0613,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0613: Unused argument, since all functions follow the same API
# W0614: Unused import %s from wildcard import (since we need cli)
......
......@@ -20,7 +20,7 @@
"""Node related commands"""
# pylint: disable-msg=W0401,W0613,W0614,C0103
# pylint: disable=W0401,W0613,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0613: Unused argument, since all functions follow the same API
# W0614: Unused import %s from wildcard import (since we need cli)
......
......@@ -20,7 +20,7 @@
"""OS scripts related commands"""
# pylint: disable-msg=W0401,W0613,W0614,C0103
# pylint: disable=W0401,W0613,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0613: Unused argument, since all functions follow the same API
# W0614: Unused import %s from wildcard import (since we need cli)
......
This diff is collapsed.
......@@ -27,13 +27,13 @@ import itertools
import operator
try:
# pylint: disable-msg=F0401
# pylint: disable=F0401
import functools
except ImportError:
functools = None
try:
# pylint: disable-msg=F0401
# pylint: disable=F0401
import roman
except ImportError:
roman = None
......@@ -45,9 +45,9 @@ except ImportError:
# modules (hmac, for example) which have changed their behavior as well from
# one version to the other.
try:
# pylint: disable-msg=F0401
# pylint: disable=F0401
# Yes, we're not using the imports in this module.
# pylint: disable-msg=W0611
# pylint: disable=W0611
from hashlib import md5 as md5_hash
from hashlib import sha1 as sha1_hash
# this additional version is needed for compatibility with the hmac module
......@@ -78,21 +78,21 @@ def _any(seq):
try:
# pylint: disable-msg=E0601
# pylint: disable-msg=W0622
# pylint: disable=E0601
# pylint: disable=W0622
all = all
except NameError:
all = _all
try:
# pylint: disable-msg=E0601
# pylint: disable-msg=W0622
# pylint: disable=E0601
# pylint: disable=W0622
any = any
except NameError:
any = _any
def partition(seq, pred=bool): # pylint: disable-msg=W0622
def partition(seq, pred=bool): # pylint: disable=W0622
"""Partition a list in two, based on the given predicate.
"""
......@@ -102,7 +102,7 @@ def partition(seq, pred=bool): # pylint: disable-msg=W0622
# Even though we're using Python's built-in "partial" function if available,
# this one is always defined for testing.
def _partial(func, *args, **keywords): # pylint: disable-msg=W0622
def _partial(func, *args, **keywords): # pylint: disable=W0622
"""Decorator with partial application of arguments and keywords.
This function was copied from Python's documentation.
......@@ -111,7 +111,7 @@ def _partial(func, *args, **keywords): # pylint: disable-msg=W0622
def newfunc(*fargs, **fkeywords):
newkeywords = keywords.copy()
newkeywords.update(fkeywords)
return func(*(args + fargs), **newkeywords) # pylint: disable-msg=W0142
return func(*(args + fargs), **newkeywords) # pylint: disable=W0142
newfunc.func = func
newfunc.args = args
......
......@@ -45,7 +45,7 @@ confirming what you already got.
"""
# pylint: disable-msg=E0203
# pylint: disable=E0203
# E0203: Access to member %r before its definition, since we use
# objects.py which doesn't explicitely initialise its members
......@@ -156,7 +156,7 @@ class ConfdClient:
"""
# we are actually called from init, so:
# pylint: disable-msg=W0201
# pylint: disable=W0201
if not isinstance(peers, list):
raise errors.ProgrammerError("peers must be a list")
# make a copy of peers, since we're going to shuffle the list, later
......
......@@ -50,7 +50,7 @@ class ConfdQuery(object):
"""
self.reader = reader
def Exec(self, query): # pylint: disable-msg=R0201,W0613
def Exec(self, query): # pylint: disable=R0201,W0613
"""Process a single UDP request from a client.
Different queries should override this function, which by defaults returns
......
......@@ -31,7 +31,7 @@ much memory.
"""
# pylint: disable-msg=R0904
# pylint: disable=R0904
# R0904: Too many public methods
import os
......@@ -374,7 +374,7 @@ class ConfigWriter:
configuration errors
"""
# pylint: disable-msg=R0914
# pylint: disable=R0914
result = []
seen_macs = []
ports = {}
......
......@@ -539,12 +539,12 @@ def _BeautifyError(err):
err.errno)
else:
return str(err)
except Exception: # pylint: disable-msg=W0703
except Exception: # pylint: disable=W0703
logging.exception("Error while handling existing error %s", err)
return "%s" % str(err)
def _HandleSigHup(reopen_fn, signum, frame): # pylint: disable-msg=W0613
def _HandleSigHup(reopen_fn, signum, frame): # pylint: disable=W0613
"""Handler for SIGHUP.
@param reopen_fn: List of callback functions for reopening log files
......
......@@ -624,7 +624,7 @@ class HttpBase(object):
return OpenSSL.SSL.Connection(ctx, sock)
def GetSslCiphers(self): # pylint: disable-msg=R0201
def GetSslCiphers(self): # pylint: disable=R0201
"""Returns the ciphers string for SSL.
"""
......@@ -638,7 +638,7 @@ class HttpBase(object):
"""
# some parameters are unused, but this is the API
# pylint: disable-msg=W0613
# pylint: disable=W0613
assert self._ssl_params, "SSL not initialized"
return (self._ssl_cert.digest("sha1") == cert.digest("sha1") and
......
......@@ -92,7 +92,7 @@ class HttpServerRequestAuthentication(object):
"""
# today we don't have per-request filtering, but we might want to
# add it in the future
# pylint: disable-msg=W0613
# pylint: disable=W0613
return self.AUTH_REALM
def AuthenticationRequired(self, req):
......@@ -106,7 +106,7 @@ class HttpServerRequestAuthentication(object):
"""
# Unused argument, method could be a function
# pylint: disable-msg=W0613,R0201
# pylint: disable=W0613,R0201
return False
def PreHandleRequest(self, req):
......
......@@ -537,7 +537,7 @@ class HttpServer(http.HttpBase, asyncore.dispatcher):
"""Called for each incoming connection
"""
# pylint: disable-msg=W0212
# pylint: disable=W0212
(connection, client_addr) = self.socket.accept()
self._CollectChildren(False)
......@@ -560,7 +560,7 @@ class HttpServer(http.HttpBase, asyncore.dispatcher):
utils.ResetTempfileModule()
self.request_executor(self, connection, client_addr)
except Exception: # pylint: disable-msg=W0703
except Exception: # pylint: disable=W0703
logging.exception("Error while handling request from %s:%s",
client_addr[0], client_addr[1])
os._exit(1)
......
......@@ -235,7 +235,7 @@ class BaseHypervisor(object):
"""
raise NotImplementedError
def MigrationInfo(self, instance): # pylint: disable-msg=R0201,W0613
def MigrationInfo(self, instance): # pylint: disable=R0201,W0613
"""Get instance information to perform a migration.
By default assume no information is needed.
......
......@@ -29,7 +29,7 @@ import time
import logging
from ganeti import constants
from ganeti import errors # pylint: disable-msg=W0611
from ganeti import errors # pylint: disable=W0611
from ganeti import utils
from ganeti import objects
from ganeti.hypervisor import hv_base
......@@ -247,7 +247,7 @@ class ChrootManager(hv_base.BaseHypervisor):
return self.GetLinuxNodeInfo()
@classmethod
def GetInstanceConsole(cls, instance, # pylint: disable-msg=W0221
def GetInstanceConsole(cls, instance, # pylint: disable=W0221
hvparams, beparams, root_dir=None):
"""Return information for connecting to the console of an instance.
......
......@@ -29,7 +29,7 @@ import time
import logging
from ganeti import constants
from ganeti import errors # pylint: disable-msg=W0611
from ganeti import errors # pylint: disable=W0611
from ganeti import utils
from ganeti import objects
from ganeti.hypervisor import hv_base
......