[rhmessaging-commits] rhmessaging commits: r2120 - mgmt/mint/python/mint.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Jun 3 16:29:57 EDT 2008


Author: nunofsantos
Date: 2008-06-03 16:29:57 -0400 (Tue, 03 Jun 2008)
New Revision: 2120

Modified:
   mgmt/mint/python/mint/__init__.py
Log:
upon Schema Mismatch error, reattempt without missing attribute

Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py	2008-06-03 17:22:06 UTC (rev 2119)
+++ mgmt/mint/python/mint/__init__.py	2008-06-03 20:29:57 UTC (rev 2120)
@@ -350,8 +350,8 @@
     self.debug = debug
 
   def log(self, message):
-    if (self.debug):
-      print message
+    #if (self.debug):
+    print message
     
   def sanitizeDict(self, d):
     if ("id" in d):
@@ -360,7 +360,7 @@
       d["clientConnectionRef"] = d.pop("connectionRef")
     #XXX FIX -- fix handling of field tables
     if ("arguments" in d):
-      d.pop("arguments")
+      print d.pop("arguments")
     #XXX FIX -- fix handling of field tables
     return d
 
@@ -477,7 +477,26 @@
 
       objStats.set(**d)
       objStats.syncUpdate()
+    except TypeError, detail:
+      self.log("TypeError: Schema mismatch: %s" % detail)
+      detailString = detail.__str__()
+      errorString = "got an unexpected keyword argument "
+      index = detailString.index(errorString)
+      if (index >= 0):
+        # argument in dict is not in schema, so remove it and re-attempt
+        index += len(errorString)
+        missingAttrib = detailString[index:]
+        self.log("Reattempting without %s attribute" % missingAttrib)
+        d.pop(missingAttrib)
+        objStats.set(**d)
+        objStats.syncUpdate()
+      else:
+        return
+    except KeyError, detail:
+      self.log("KeyError: Schema mismatch: %s" % detail)
+      return 
 
+    try:
       d = dict()
       if (timestamps[2] != 0):
         d["deletionTime"] = datetime.fromtimestamp(timestamps[2]/1000000000)
@@ -488,7 +507,19 @@
       obj.syncUpdate()
     except TypeError, detail:
       self.log("TypeError: Schema mismatch: %s" % detail)
-      return
+      detailString = detail.__str__()
+      errorString = "got an unexpected keyword argument "
+      index = detailString.index(errorString)
+      if (index >= 0):
+        # argument in dict is not in schema, so remove it and re-attempt
+        index += len(errorString)
+        missingAttrib = detailString[index:]
+        self.log("Reattempting without %s attribute" % missingAttrib)
+        d.pop(missingAttrib)
+        obj.set(**d)
+        obj.syncUpdate()
+      else:
+        return
     except KeyError, detail:
       self.log("KeyError: Schema mismatch: %s" % detail)
       return 




More information about the rhmessaging-commits mailing list