deeper pass on xmlrpclib vs xmlrpc.client as well as configparser
[sfa.git] / sfa / trust / sfaticket.py
index 018d929..6d4a009 100644 (file)
@@ -1,12 +1,36 @@
+#----------------------------------------------------------------------
+# Copyright (c) 2008 Board of Trustees, Princeton University
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and/or hardware specification (the "Work") to
+# deal in the Work without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Work, and to permit persons to whom the Work
+# is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Work.
+#
+# THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS
+# IN THE WORK.
+#----------------------------------------------------------------------
 #
 # implements SFA tickets
 #
 
-import xmlrpclib
+from __future__ import print_function
 
 from sfa.trust.certificate import Certificate
 from sfa.trust.gid import GID
 
+from sfa.util.py23 import xmlrpc_client
+
 # Ticket is tuple:
 #   (gidCaller, gidObject, attributes, rspec, delegate)
 #
@@ -75,13 +99,13 @@ class SfaTicket(Certificate):
             dict["gidCaller"] = self.gidCaller.save_to_string(save_parents=True)
         if self.gidObject:
             dict["gidObject"] = self.gidObject.save_to_string(save_parents=True)
-        str = "URI:" + xmlrpclib.dumps((dict,), allow_none=True)
+        str = "URI:" + xmlrpc_client.dumps((dict,), allow_none=True)
         self.set_data(str)
 
     def decode(self):
         data = self.get_data()
         if data:
-            dict = xmlrpclib.loads(self.get_data()[4:])[0][0]
+            dict = xmlrpc_client.loads(self.get_data()[4:])[0][0]
         else:
             dict = {}
 
@@ -102,25 +126,25 @@ class SfaTicket(Certificate):
             self.gidObject = None
 
     def dump(self, dump_parents=False):
-        print "TICKET", self.get_subject()
+        print("TICKET", self.get_subject())
 
-        print "  gidCaller:"
+        print("  gidCaller:")
         gidCaller = self.get_gid_caller()
         if gidCaller:
             gidCaller.dump(8, dump_parents)
 
-        print "  gidObject:"
+        print("  gidObject:")
         gidObject = self.get_gid_object()
         if gidObject:
             gidObject.dump(8, dump_parents)
 
-        print "  attributes:"
+        print("  attributes:")
         for attrname in self.get_attributes().keys():
-            print "        ", attrname, self.get_attributes()[attrname]
+            print("        ", attrname, self.get_attributes()[attrname])
 
-        print "       rspec:"
-        print "        ", self.get_rspec()
+        print("       rspec:")
+        print("        ", self.get_rspec())
 
         if self.parent and dump_parents:
-           print "PARENT",
+           print("PARENT", end=' ')
            self.parent.dump(dump_parents)