Commit 7260cfbe authored by Iustin Pop's avatar Iustin Pop
Browse files

Add targeted pylint disables



This patch should have only:

- pylint disables
- docstring changes
- whitespace changes
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarOlivier Tharan <olive@google.com>
parent e7beaa02
......@@ -26,11 +26,12 @@ pass to and from external parties.
"""
# pylint: disable-msg=E0203
# pylint: disable-msg=E0203,W0201
# E0203: Access to member %r before its definition, since we use
# objects.py which doesn't explicitely initialise its members
# W0201: Attribute '%s' defined outside __init__
import ConfigParser
import re
......@@ -153,7 +154,7 @@ class ConfigObject(object):
raise errors.ConfigurationError("Invalid object passed to FromDict:"
" expected dict, got %s" % type(val))
val_str = dict([(str(k), v) for k, v in val.iteritems()])
obj = cls(**val_str)
obj = cls(**val_str) # pylint: disable-msg=W0142
return obj
@staticmethod
......
......@@ -18,5 +18,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Ganeti RAPI module"""
RAPI_ACCESS_WRITE = "write"
......@@ -672,6 +672,7 @@ class _R_Tags(baserlib.R_Generic):
Example: ["tag1", "tag2", "tag3"]
"""
# pylint: disable-msg=W0212
return baserlib._Tags_GET(self.TAG_LEVEL, name=self.name)
def PUT(self):
......@@ -681,6 +682,7 @@ class _R_Tags(baserlib.R_Generic):
you'll have back a job id.
"""
# pylint: disable-msg=W0212
if 'tag' not in self.queryargs:
raise http.HttpBadRequest("Please specify tag(s) to add using the"
" the 'tag' parameter")
......@@ -696,6 +698,7 @@ class _R_Tags(baserlib.R_Generic):
/tags?tag=[tag]&tag=[tag]
"""
# pylint: disable-msg=W0212
if 'tag' not in self.queryargs:
# no we not gonna delete all tags
raise http.HttpBadRequest("Cannot delete all tags - please specify"
......
......@@ -163,7 +163,7 @@ class RpcResult(object):
args = (msg, prereq)
else:
args = (msg, )
raise ec(*args)
raise ec(*args) # pylint: disable-msg=W0142
class Client:
......
......@@ -23,6 +23,14 @@
"""
# pylint: disable-msg=W0232,R0201
# W0232, since we use these as singletons rather than object holding
# data
# R0201, for the same reason
# TODO: FileStorage initialised with paths whereas the others not
import logging
......@@ -50,7 +58,7 @@ class _Base:
"""
raise NotImplementedError()
def Modify(self, name, changes):
def Modify(self, name, changes): # pylint: disable-msg=W0613
"""Modifies an entity within the storage unit.
@type name: string
......@@ -76,7 +84,7 @@ class _Base:
raise NotImplementedError()
class FileStorage(_Base):
class FileStorage(_Base): # pylint: disable-msg=W0223
"""File storage unit.
"""
......@@ -153,7 +161,7 @@ class FileStorage(_Base):
return values
class _LvmBase(_Base):
class _LvmBase(_Base): # pylint: disable-msg=W0223
"""Base class for LVM storage containers.
@cvar LIST_FIELDS: list of tuples consisting of three elements: SF_*
......@@ -248,7 +256,7 @@ class _LvmBase(_Base):
if callable(mapper):
# we got a function, call it with all the declared fields
val = mapper(*values)
val = mapper(*values) # pylint: disable-msg=W0142
elif len(values) == 1:
# we don't have a function, but we had a single field
# declared, pass it unchanged
......@@ -324,7 +332,7 @@ class _LvmBase(_Base):
yield fields
class LvmPvStorage(_LvmBase):
class LvmPvStorage(_LvmBase): # pylint: disable-msg=W0223
"""LVM Physical Volume storage unit.
"""
......
......@@ -1369,14 +1369,14 @@ def FirstFree(seq, base=0):
return None
def all(seq, pred=bool):
def all(seq, pred=bool): # pylint: disable-msg=W0622
"Returns True if pred(x) is True for every element in the iterable"
for _ in itertools.ifilterfalse(pred, seq):
return False
return True
def any(seq, pred=bool):
def any(seq, pred=bool): # pylint: disable-msg=W0622
"Returns True if pred(x) is True for at least one element in the iterable"
for _ in itertools.ifilter(pred, seq):
return True
......@@ -1493,6 +1493,8 @@ def Daemonize(logfile):
@return: the value zero
"""
# pylint: disable-msg=W0212
# yes, we really want os._exit
UMASK = 077
WORKDIR = "/"
......@@ -1567,7 +1569,7 @@ def RemovePidFile(name):
# TODO: we could check here that the file contains our pid
try:
RemoveFile(pidfilename)
except:
except: # pylint: disable-msg=W0702
pass
......@@ -1958,6 +1960,7 @@ def LockedMethod(fn):
logging.debug(*args, **kwargs)
def wrapper(self, *args, **kwargs):
# pylint: disable-msg=W0212
assert hasattr(self, '_lock')
lock = self._lock
_LockDebug("Waiting for %s", lock)
......@@ -2164,6 +2167,7 @@ def Retry(fn, delay, timeout, args=None, wait_fn=time.sleep,
while True:
try:
# pylint: disable-msg=W0142
return fn(*args)
except RetryAgain:
pass
......
......@@ -34,6 +34,7 @@ class BaseWorker(threading.Thread, object):
Users of a worker pool must override RunTask in a subclass.
"""
# pylint: disable-msg=W0212
def __init__(self, pool, worker_id):
"""Constructor for BaseWorker thread.
......@@ -118,7 +119,7 @@ class BaseWorker(threading.Thread, object):
self.RunTask(*self._current_task)
logging.debug("Worker %s: done with task %r",
self.worker_id, self._current_task)
except:
except: # pylint: disable-msg=W0702
logging.error("Worker %s: Caught unhandled exception",
self.worker_id, exc_info=True)
finally:
......@@ -223,7 +224,7 @@ class WorkerPool(object):
"""
for worker in self._workers + self._termworkers:
if worker._HasRunningTaskUnlocked():
if worker._HasRunningTaskUnlocked(): # pylint: disable-msg=W0212
return True
return False
......
......@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Backup related commands"""
# pylint: disable-msg=W0401,W0614
# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-backup
import sys
......
......@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Cluster related commands"""
# pylint: disable-msg=W0401,W0614
# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-cluster
import sys
import os.path
......
......@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Debugging commands"""
# pylint: disable-msg=W0401,W0614
# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-backup
import sys
import simplejson
......@@ -77,6 +79,7 @@ def GenericOpCodes(opts, args):
ToStdout("Loading...")
for job_idx in range(opts.rep_job):
for fname in args:
# pylint: disable-msg=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
......
......@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Instance related commands"""
# pylint: disable-msg=W0401,W0614
# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-instance
import sys
import os
......@@ -75,6 +77,7 @@ def _ExpandMultiNames(mode, names, client=None):
@raise errors.OpPrereqError: for invalid input parameters
"""
# pylint: disable-msg=W0142
if client is None:
client = GetClient()
if mode == _SHUTDOWN_CLUSTER:
......@@ -395,7 +398,7 @@ def BatchCreate(opts, args):
json_filename = args[0]
try:
instance_data = simplejson.loads(utils.ReadFile(json_filename))
except Exception, err:
except Exception, err: # pylint: disable-msg=W0703
ToStderr("Can't parse the instance definition file: %s" % str(err))
return 1
......@@ -911,7 +914,7 @@ def ConnectToInstanceConsole(opts, args):
finally:
ToStderr("Can't run console command %s with arguments:\n'%s'",
cmd[0], " ".join(cmd))
os._exit(1)
os._exit(1) # pylint: disable-msg=W0212
def _FormatLogicalID(dev_type, logical_id):
......
......@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Job related commands"""
# pylint: disable-msg=W0401,W0614
# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-job
import sys
......
......@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Node related commands"""
# pylint: disable-msg=W0401,W0614
# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-node
import sys
......
......@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""OS scripts related commands"""
# pylint: disable-msg=W0401,W0614
# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-os
import sys
......
......@@ -83,8 +83,9 @@ def Err(msg, exit_code=1):
class SimpleOpener(urllib.FancyURLopener):
"""A simple url opener"""
# pylint: disable-msg=W0221
def prompt_user_passwd(self, host, realm, clear_cache = 0):
def prompt_user_passwd(self, host, realm, clear_cache=0):
"""No-interaction version of prompt_user_passwd."""
return None, None
......@@ -208,7 +209,7 @@ def _DoCheckInstances(fn):
def wrapper(self, *args, **kwargs):
val = fn(self, *args, **kwargs)
for instance in self.instances:
self._CheckInstanceAlive(instance)
self._CheckInstanceAlive(instance) # pylint: disable-msg=W0212
return val
return wrapper
......@@ -289,7 +290,7 @@ class Burner(object):
Log("Idempotent %s succeeded after %d retries" %
(msg, MAX_RETRIES - retry_count))
return val
except Exception, err:
except Exception, err: # pylint: disable-msg=W0703
if retry_count == 0:
Log("Non-idempotent %s failed, aborting" % (msg, ))
raise
......@@ -377,7 +378,7 @@ class Burner(object):
Log("waiting for job %s for %s" % (jid, iname), indent=2)
try:
results.append(cli.PollJob(jid, cl=self.cl, feedback_fn=self.Feedback))
except Exception, err:
except Exception, err: # pylint: disable-msg=W0703
Log("Job for %s failed: %s" % (iname, err))
if len(results) != len(jobs):
raise BurninFailure()
......@@ -544,7 +545,7 @@ class Burner(object):
disks=[i for i in range(self.disk_count)])
Log("run %s" % mode, indent=2)
ops.append(op)
self.ExecOrQueue(instance, *ops)
self.ExecOrQueue(instance, *ops) # pylint: disable-msg=W0142
@_DoBatch(True)
def BurnReplaceDisks2(self):
......@@ -760,7 +761,7 @@ class Burner(object):
ignore_secondaries=False)
Log("reboot with type '%s'" % reboot_type, indent=2)
ops.append(op)
self.ExecOrQueue(instance, *ops)
self.ExecOrQueue(instance, *ops) # pylint: disable-msg=W0142
@_DoCheckInstances
@_DoBatch(True)
......@@ -913,7 +914,7 @@ class Burner(object):
if not self.opts.keep_instances:
try:
self.BurnRemove()
except Exception, err:
except Exception, err: # pylint: disable-msg=W0703
if has_err: # already detected errors, so errors in removal
# are quite expected
Log("Note: error detected during instance remove: %s" % str(err))
......
......@@ -152,7 +152,7 @@ class ConfigShell(cmd.Cmd):
arg = None
try:
self.cfg = config.ConfigWriter(cfg_file=arg, offline=True)
self.parents = [self.cfg._config_data]
self.parents = [self.cfg._config_data] # pylint: disable-msg=W0212
self.path = []
except errors.ConfigurationError, err:
print "Error: %s" % str(err)
......@@ -284,7 +284,7 @@ class ConfigShell(cmd.Cmd):
if self.cfg.VerifyConfig():
print "Config data does not validate, refusing to save."
return False
self.cfg._WriteConfig()
self.cfg._WriteConfig() # pylint: disable-msg=W0212
def do_rm(self, line):
"""Removes an instance or a node.
......@@ -294,7 +294,7 @@ class ConfigShell(cmd.Cmd):
"""
pointer = self.parents[-1]
data = self.cfg._config_data
data = self.cfg._config_data # pylint: disable-msg=W0212
if pointer not in (data.instances, data.nodes):
print "Can only delete instances and nodes"
return False
......
......@@ -98,7 +98,7 @@ def main():
"""Main program.
"""
global options, args
global options, args # pylint: disable-msg=W0603
program = os.path.basename(sys.argv[0])
......
......@@ -130,7 +130,7 @@ def ParseOptions():
Returns:
(options, args), as returned by OptionParser.parse_args
"""
global verbose_flag
global verbose_flag # pylint: disable-msg=W0603
parser = optparse.OptionParser(usage="\n%s" % USAGE,
version="%%prog (ganeti) %s" %
......
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