ensure-dirs: Set permissions on queue lock file
[ganeti-local] / lib / serializer.py
index 9a5f1ce..81f1add 100644 (file)
@@ -38,7 +38,7 @@ from ganeti import utils
 
 _JSON_INDENT = 2
 
-_RE_EOLSP = re.compile('[ \t]+$', re.MULTILINE)
+_RE_EOLSP = re.compile("[ \t]+$", re.MULTILINE)
 
 
 def _GetJsonDumpers(_encoder_class=simplejson.JSONEncoder):
@@ -79,8 +79,8 @@ def DumpJson(data, indent=True):
     fn = _DumpJson
 
   txt = _RE_EOLSP.sub("", fn(data))
-  if not txt.endswith('\n'):
-    txt += '\n'
+  if not txt.endswith("\n"):
+    txt += "\n"
 
   return txt
 
@@ -108,10 +108,10 @@ def DumpSignedJson(data, key, salt=None, key_selector=None):
   """
   txt = DumpJson(data, indent=False)
   if salt is None:
-    salt = ''
+    salt = ""
   signed_dict = {
-    'msg': txt,
-    'salt': salt,
+    "msg": txt,
+    "salt": salt,
     }
 
   if key_selector:
@@ -138,13 +138,13 @@ def LoadSignedJson(txt, key):
   """
   signed_dict = LoadJson(txt)
   if not isinstance(signed_dict, dict):
-    raise errors.SignatureError('Invalid external message')
+    raise errors.SignatureError("Invalid external message")
   try:
-    msg = signed_dict['msg']
-    salt = signed_dict['salt']
-    hmac_sign = signed_dict['hmac']
+    msg = signed_dict["msg"]
+    salt = signed_dict["salt"]
+    hmac_sign = signed_dict["hmac"]
   except KeyError:
-    raise errors.SignatureError('Invalid external message')
+    raise errors.SignatureError("Invalid external message")
 
   if callable(key):
     # pylint: disable-msg=E1103
@@ -159,7 +159,7 @@ def LoadSignedJson(txt, key):
 
   if not utils.VerifySha1Hmac(hmac_key, msg, hmac_sign,
                               salt=salt + key_selector):
-    raise errors.SignatureError('Invalid Signature')
+    raise errors.SignatureError("Invalid Signature")
 
   return LoadJson(msg), salt