Fix new pylint errors
authorGuido Trotter <ultrotter@google.com>
Fri, 9 Apr 2010 14:46:13 +0000 (15:46 +0100)
committerGuido Trotter <ultrotter@google.com>
Fri, 9 Apr 2010 14:54:46 +0000 (15:54 +0100)
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 <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

daemons/ganeti-masterd
lib/serializer.py
scripts/gnt-instance

index 8d7cd1d..229f0c8 100755 (executable)
@@ -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
index 314a934..47365f0 100644 (file)
@@ -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:
index 4063253..4f6ddc8 100755 (executable)
@@ -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)