Commit fe267188 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add targetted pylint disables



This patch adds targeted pylint disables, where it makes sense (either
due to limitations in pylint or due to historical usage), and also a few
blanket ones in rapi where all the names are… “different”.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarOlivier Tharan <olive@google.com>
parent caeffaa0
...@@ -20,3 +20,5 @@ ...@@ -20,3 +20,5 @@
# empty file for package definition # empty file for package definition
"""Ganeti python modules"""
...@@ -1151,6 +1151,7 @@ def BlockdevCreate(disk, size, owner, on_primary, info): ...@@ -1151,6 +1151,7 @@ def BlockdevCreate(disk, size, owner, on_primary, info):
# we need the children open in case the device itself has to # we need the children open in case the device itself has to
# be assembled # be assembled
try: try:
# pylint: disable-msg=E1103
crdev.Open() crdev.Open()
except errors.BlockDeviceError, err: except errors.BlockDeviceError, err:
errmsg = "Can't make child '%s' read-write: %s" % (child, err) errmsg = "Can't make child '%s' read-write: %s" % (child, err)
...@@ -1297,6 +1298,7 @@ def BlockdevAssemble(disk, owner, as_primary): ...@@ -1297,6 +1298,7 @@ def BlockdevAssemble(disk, owner, as_primary):
try: try:
result = _RecursiveAssembleBD(disk, owner, as_primary) result = _RecursiveAssembleBD(disk, owner, as_primary)
if isinstance(result, bdev.BlockDev): if isinstance(result, bdev.BlockDev):
# pylint: disable-msg=E1103
result = result.dev_path result = result.dev_path
except errors.BlockDeviceError, err: except errors.BlockDeviceError, err:
result = "Error while assembling disk: %s" % str(err) result = "Error while assembling disk: %s" % str(err)
...@@ -2510,7 +2512,9 @@ class HooksRunner(object): ...@@ -2510,7 +2512,9 @@ class HooksRunner(object):
""" """
if hooks_base_dir is None: if hooks_base_dir is None:
hooks_base_dir = constants.HOOKS_BASE_DIR hooks_base_dir = constants.HOOKS_BASE_DIR
self._BASE_DIR = 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
@staticmethod @staticmethod
def ExecHook(script, env): def ExecHook(script, env):
......
...@@ -720,7 +720,7 @@ class DRBD8Status(object): ...@@ -720,7 +720,7 @@ class DRBD8Status(object):
self.est_time = None self.est_time = None
class BaseDRBD(BlockDev): class BaseDRBD(BlockDev): # pylint: disable-msg=W0223
"""Base DRBD class. """Base DRBD class.
This class contains a few bits of common functionality between the This class contains a few bits of common functionality between the
......
...@@ -198,12 +198,12 @@ SYNC_OPT = make_option("--sync", dest="do_locking", ...@@ -198,12 +198,12 @@ SYNC_OPT = make_option("--sync", dest="do_locking",
" in order to ensure more consistent results") " in order to ensure more consistent results")
def ARGS_FIXED(val): def ARGS_FIXED(val): # pylint: disable-msg=C0103
"""Macro-like function denoting a fixed number of arguments""" """Macro-like function denoting a fixed number of arguments"""
return -val return -val
def ARGS_ATLEAST(val): def ARGS_ATLEAST(val): # pylint: disable-msg=C0103
"""Macro-like function denoting a minimum number of arguments""" """Macro-like function denoting a minimum number of arguments"""
return val return val
...@@ -797,8 +797,8 @@ def GenerateTable(headers, fields, separator, data, ...@@ -797,8 +797,8 @@ def GenerateTable(headers, fields, separator, data,
if unitfields is None: if unitfields is None:
unitfields = [] unitfields = []
numfields = utils.FieldSet(*numfields) numfields = utils.FieldSet(*numfields) # pylint: disable-msg=W0142
unitfields = utils.FieldSet(*unitfields) unitfields = utils.FieldSet(*unitfields) # pylint: disable-msg=W0142
format_fields = [] format_fields = []
for field in fields: for field in fields:
......
...@@ -84,8 +84,8 @@ class LogicalUnit(object): ...@@ -84,8 +84,8 @@ class LogicalUnit(object):
self.recalculate_locks = {} self.recalculate_locks = {}
self.__ssh = None self.__ssh = None
# logging # logging
self.LogWarning = processor.LogWarning self.LogWarning = processor.LogWarning # pylint: disable-msg=C0103
self.LogInfo = processor.LogInfo self.LogInfo = processor.LogInfo # pylint: disable-msg=C0103
for attr_name in self._OP_REQP: for attr_name in self._OP_REQP:
attr_val = getattr(op, attr_name, None) attr_val = getattr(op, attr_name, None)
...@@ -322,7 +322,7 @@ class LogicalUnit(object): ...@@ -322,7 +322,7 @@ class LogicalUnit(object):
del self.recalculate_locks[locking.LEVEL_NODE] del self.recalculate_locks[locking.LEVEL_NODE]
class NoHooksLU(LogicalUnit): class NoHooksLU(LogicalUnit): # pylint: disable-msg=W0223
"""Simple LU which runs no hooks. """Simple LU which runs no hooks.
This LU is intended as a parent for other LogicalUnits which will This LU is intended as a parent for other LogicalUnits which will
...@@ -6635,7 +6635,7 @@ class LURemoveExport(NoHooksLU): ...@@ -6635,7 +6635,7 @@ class LURemoveExport(NoHooksLU):
" Domain Name.") " Domain Name.")
class TagsLU(NoHooksLU): class TagsLU(NoHooksLU): # pylint: disable-msg=W0223
"""Generic tags LU. """Generic tags LU.
This is an abstract class which is the parent of all the other tags LUs. This is an abstract class which is the parent of all the other tags LUs.
......
...@@ -254,7 +254,7 @@ class HttpClientRequestExecutor(http.HttpBase): ...@@ -254,7 +254,7 @@ class HttpClientRequestExecutor(http.HttpBase):
# Do the secret SSL handshake # Do the secret SSL handshake
if self.using_ssl: if self.using_ssl:
self.sock.set_connect_state() self.sock.set_connect_state() # pylint: disable-msg=E1103
try: try:
http.Handshake(self.sock, self.WRITE_TIMEOUT) http.Handshake(self.sock, self.WRITE_TIMEOUT)
except http.HttpSessionHandshakeUnexpectedEOF: except http.HttpSessionHandshakeUnexpectedEOF:
......
...@@ -130,11 +130,12 @@ def InitAndVerifyQueue(must_lock): ...@@ -130,11 +130,12 @@ def InitAndVerifyQueue(must_lock):
if serial is None: if serial is None:
# There must be a serious problem # There must be a serious problem
raise errors.JobQueueError("Can't read/parse the job queue serial file") raise errors.JobQueueError("Can't read/parse the job queue"
" serial file")
if not must_lock: if not must_lock:
# There's no need for more error handling. Closing the lock file below in # There's no need for more error handling. Closing the lock
# case of an error will unlock it anyway. # file below in case of an error will unlock it anyway.
queue_lock.Unlock() queue_lock.Unlock()
except: except:
......
...@@ -753,7 +753,7 @@ class GanetiLockManager: ...@@ -753,7 +753,7 @@ class GanetiLockManager:
# the test cases. # the test cases.
return utils.any((self._is_owned(l) for l in LEVELS[level + 1:])) return utils.any((self._is_owned(l) for l in LEVELS[level + 1:]))
def _BGL_owned(self): def _BGL_owned(self): # pylint: disable-msg=C0103
"""Check if the current thread owns the BGL. """Check if the current thread owns the BGL.
Both an exclusive or a shared acquisition work. Both an exclusive or a shared acquisition work.
...@@ -761,7 +761,7 @@ class GanetiLockManager: ...@@ -761,7 +761,7 @@ class GanetiLockManager:
""" """
return BGL in self.__keyring[LEVEL_CLUSTER]._list_owned() return BGL in self.__keyring[LEVEL_CLUSTER]._list_owned()
def _contains_BGL(self, level, names): def _contains_BGL(self, level, names): # pylint: disable-msg=C0103
"""Check if the level contains the BGL. """Check if the level contains the BGL.
Check if acting on the given level and set of names will change Check if acting on the given level and set of names will change
......
...@@ -100,7 +100,7 @@ class Processor(object): ...@@ -100,7 +100,7 @@ class Processor(object):
""" """
self.context = context self.context = context
self._feedback_fn = None self._feedback_fn = None
self.exclusive_BGL = False self.exclusive_BGL = False # pylint: disable-msg=C0103
self.rpc = rpc.RpcRunner(context.cfg) self.rpc = rpc.RpcRunner(context.cfg)
def _ExecLU(self, lu): def _ExecLU(self, lu):
......
...@@ -786,6 +786,8 @@ class Cluster(TaggableObject): ...@@ -786,6 +786,8 @@ class Cluster(TaggableObject):
"""Fill defaults for missing configuration values. """Fill defaults for missing configuration values.
""" """
# pylint: disable-msg=E0203
# because these are "defined" via slots, not manually
if self.hvparams is None: if self.hvparams is None:
self.hvparams = constants.HVC_DEFAULTS self.hvparams = constants.HVC_DEFAULTS
else: else:
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
""" """
# pylint: disable-msg=C0103
# C0103: Invalid name, since the R_* names are not conforming
import logging import logging
from ganeti import luxi from ganeti import luxi
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
""" """
# pylint: disable-msg=C0103
# C0103: Invalid name, since the R_* names are not conforming
import cgi import cgi
import re import re
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
""" """
# pylint: disable-msg=C0103
# C0103: Invalid name, since the R_* names are not conforming
from ganeti import opcodes from ganeti import opcodes
from ganeti import http from ganeti import http
from ganeti import constants from ganeti import constants
...@@ -30,7 +34,6 @@ from ganeti import cli ...@@ -30,7 +34,6 @@ from ganeti import cli
from ganeti.rapi import baserlib from ganeti.rapi import baserlib
I_FIELDS = ["name", "admin_state", "os", I_FIELDS = ["name", "admin_state", "os",
"pnode", "snodes", "pnode", "snodes",
"disk_template", "disk_template",
......
...@@ -42,7 +42,8 @@ from ganeti import serializer ...@@ -42,7 +42,8 @@ from ganeti import serializer
from ganeti import constants from ganeti import constants
from ganeti import errors from ganeti import errors
import ganeti.http.client # pylint has a bug here, doesn't see this import
import ganeti.http.client # pylint: disable-msg=W0611
# Module level variable # Module level variable
...@@ -55,7 +56,7 @@ def Init(): ...@@ -55,7 +56,7 @@ def Init():
Must be called before using any RPC function. Must be called before using any RPC function.
""" """
global _http_manager global _http_manager # pylint: disable-msg=W0603
assert not _http_manager, "RPC module initialized more than once" assert not _http_manager, "RPC module initialized more than once"
...@@ -68,7 +69,7 @@ def Shutdown(): ...@@ -68,7 +69,7 @@ def Shutdown():
Must be called before quitting the program. Must be called before quitting the program.
""" """
global _http_manager global _http_manager # pylint: disable-msg=W0603
if _http_manager: if _http_manager:
_http_manager.Shutdown() _http_manager.Shutdown()
......
...@@ -24,6 +24,10 @@ This module introduces a simple abstraction over the serialization ...@@ -24,6 +24,10 @@ This module introduces a simple abstraction over the serialization
backend (currently json). backend (currently json).
""" """
# pylint: disable-msg=C0103
# C0103: Invalid name, since pylint doesn't see that Dump points to a
# function and not a constant
import simplejson import simplejson
import re import re
......
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