From fe7c59d515b3f983331e2e596740920268e03a20 Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Fri, 9 Apr 2010 15:46:13 +0100 Subject: [PATCH] Fix new pylint errors Under squeeze pylint reports the following errors: ************* Module ganeti.serializer E1103:155:LoadSignedJson: Instance of 'False' has no 'get' member (but some types could not be inferred) ************* Module ganeti-masterd E1103:166:ClientRqHandler.handle: Instance of 'False' has no 'get' member (but some types could not be inferred) E1103:167:ClientRqHandler.handle: Instance of 'False' has no 'get' member (but some types could not be inferred) ************* Module gnt-instance E1103:431:BatchCreate: Instance of 'False' has no 'keys' member (but some types could not be inferred) For the first two cases it's actually wrong: we had checked before that the variable on which "get" is called is actually a dict. In the third case though such check doesn't exist, so we add it. Then we silence the error all three times. Signed-off-by: Guido Trotter Reviewed-by: Iustin Pop --- daemons/ganeti-masterd | 4 ++-- lib/serializer.py | 1 + scripts/gnt-instance | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd index 8d7cd1d..229f0c8 100755 --- a/daemons/ganeti-masterd +++ b/daemons/ganeti-masterd @@ -163,8 +163,8 @@ class ClientRqHandler(SocketServer.BaseRequestHandler): logging.error("wrong request received: %s", msg) break - method = request.get(luxi.KEY_METHOD, None) - args = request.get(luxi.KEY_ARGS, None) + method = request.get(luxi.KEY_METHOD, None) # pylint: disable-msg=E1103 + args = request.get(luxi.KEY_ARGS, None) # pylint: disable-msg=E1103 if method is None or args is None: logging.error("no method or args in request") break diff --git a/lib/serializer.py b/lib/serializer.py index 314a934..47365f0 100644 --- a/lib/serializer.py +++ b/lib/serializer.py @@ -152,6 +152,7 @@ def LoadSignedJson(txt, key): raise errors.SignatureError('Invalid external message') if callable(key): + # pylint: disable-msg=E1103 key_selector = signed_dict.get("key_selector", None) hmac_key = key(key_selector) if not hmac_key: diff --git a/scripts/gnt-instance b/scripts/gnt-instance index 4063253..4f6ddc8 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -423,12 +423,16 @@ def BatchCreate(opts, args): ToStderr("Can't parse the instance definition file: %s" % str(err)) return 1 + if not isinstance(instance_data, dict): + ToStderr("The instance definition file is not in dict format.") + return 1 + jex = JobExecutor(opts=opts) # Iterate over the instances and do: # * Populate the specs with default value # * Validate the instance specs - i_names = utils.NiceSort(instance_data.keys()) + i_names = utils.NiceSort(instance_data.keys()) # pylint: disable-msg=E1103 for name in i_names: specs = instance_data[name] specs = _PopulateWithDefaults(specs) -- 1.7.10.4