remove py23 compat layer
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 29 Mar 2019 15:43:00 +0000 (16:43 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 29 Mar 2019 15:43:00 +0000 (16:43 +0100)
31 files changed:
clientbin/getNodes.py
config/sfa-config-tty
sfa/client/manifolduploader.py
sfa/client/sfaserverproxy.py
sfa/client/sfi.py
sfa/dummy/dummy_testbed_api_client.py
sfa/dummy/dummyshell.py
sfa/planetlab/peers.py
sfa/rspecs/pg_rspec_converter.py
sfa/rspecs/version_manager.py
sfa/rspecs/versions/pgv2.py
sfa/server/threadedserver.py
sfa/server/xmlrpcapi.py
sfa/storage/model.py
sfa/storage/parameter.py
sfa/storage/record.py
sfa/trust/abac_credential.py
sfa/trust/auth.py
sfa/trust/certificate.py
sfa/trust/credential.py
sfa/trust/gid.py
sfa/trust/sfaticket.py
sfa/trust/speaksfor_util.py
sfa/util/config.py
sfa/util/faults.py
sfa/util/method.py
sfa/util/py23.py [deleted file]
sfa/util/sfatime.py
sfa/util/xml.py
sfatables/commands/moo.py
tests/testCert.py

index aa0a4b1..69abf48 100644 (file)
@@ -5,9 +5,6 @@ import os
 from optparse import OptionParser
 from pprint import pprint
 
-from sfa.util.py23 import StringType
-
-
 def create_parser():
     command = sys.argv[0]
     argv = sys.argv[1:]
@@ -37,7 +34,7 @@ def print_dict(rdict, options, counter=1):
     if not isinstance(rdict, dict):
         raise "%s not a dict" % rdict
     for (key, value) in rdict.items():
-        if isinstance(value, StringType):
+        if isinstance(value, str):
             if (attributes and key in attributes) or not attributes:
                 print(tab * counter + "%s: %s" % (key, value))
         elif isinstance(value, list):
index c97b963..f7c234b 100755 (executable)
@@ -3,11 +3,8 @@
 import os
 import sys
 import re
-#import time
 import traceback
-#import types
 import readline
-#from io import StringIO
 from optparse import OptionParser
 
 from sfa.util.version import version_tag
index c469b35..8d1d74e 100755 (executable)
@@ -34,7 +34,7 @@ except:
 
 import getpass
 
-from sfa.util.py23 import xmlrpc_client
+import xmlrpc.client
 
 
 class ManifoldUploader:
@@ -91,11 +91,11 @@ class ManifoldUploader:
         #        if not self._proxy:
         #            url=self.url()
         #            self.logger.info("Connecting manifold url %s"%url)
-        #            self._proxy = xmlrpc_client.ServerProxy(url, allow_none = True)
+        #            self._proxy = xmlrpc.client.ServerProxy(url, allow_none = True)
         #        return self._proxy
         url = self.url()
         self.logger.debug("Connecting manifold url %s" % url)
-        proxy = xmlrpc_client.ServerProxy(url, allow_none=True,
+        proxy = xmlrpc.client.ServerProxy(url, allow_none=True,
                                           **turn_off_server_verify)
 
         return proxy
index 73aefc8..457a1d2 100644 (file)
@@ -7,8 +7,8 @@ try:
 except:
     turn_off_server_verify = {}
 
-from sfa.util.py23 import xmlrpc_client
-from sfa.util.py23 import http_client
+import xmlrpc.client
+import http.client
 
 try:
     from sfa.util.sfalogging import logger
@@ -27,12 +27,12 @@ class ServerException(Exception):
     pass
 
 
-class ExceptionUnmarshaller(xmlrpc_client.Unmarshaller):
+class ExceptionUnmarshaller(xmlrpc.client.Unmarshaller):
 
     def close(self):
         try:
-            return xmlrpc_client.Unmarshaller.close(self)
-        except xmlrpc_client.Fault as e:
+            return xmlrpc.client.Unmarshaller.close(self)
+        except xmlrpc.client.Fault as e:
             raise ServerException(e.faultString)
 
 ##
@@ -43,10 +43,10 @@ class ExceptionUnmarshaller(xmlrpc_client.Unmarshaller):
 # targetting only python-2.7 we can get rid of some older code
 
 
-class XMLRPCTransport(xmlrpc_client.Transport):
+class XMLRPCTransport(xmlrpc.client.Transport):
 
     def __init__(self, key_file=None, cert_file=None, timeout=None):
-        xmlrpc_client.Transport.__init__(self)
+        xmlrpc.client.Transport.__init__(self)
         self.timeout = timeout
         self.key_file = key_file
         self.cert_file = cert_file
@@ -55,7 +55,7 @@ class XMLRPCTransport(xmlrpc_client.Transport):
         # create a HTTPS connection object from a host descriptor
         # host may be a string, or a (host, x509-dict) tuple
         host, extra_headers, x509 = self.get_host_info(host)
-        conn = http_client.HTTPSConnection(host, None, key_file=self.key_file,
+        conn = http.client.HTTPSConnection(host, None, key_file=self.key_file,
                                            cert_file=self.cert_file,
                                            **turn_off_server_verify)
 
@@ -80,23 +80,23 @@ class XMLRPCTransport(xmlrpc_client.Transport):
 
     def getparser(self):
         unmarshaller = ExceptionUnmarshaller()
-        parser = xmlrpc_client.ExpatParser(unmarshaller)
+        parser = xmlrpc.client.ExpatParser(unmarshaller)
         return parser, unmarshaller
 
 
-class XMLRPCServerProxy(xmlrpc_client.ServerProxy):
+class XMLRPCServerProxy(xmlrpc.client.ServerProxy):
 
     def __init__(self, url, transport, allow_none=True, verbose=False):
         # remember url for GetVersion
         # xxx not sure this is still needed as SfaServerProxy has this too
         self.url = url
-        xmlrpc_client.ServerProxy.__init__(self, url, transport, allow_none=allow_none,
+        xmlrpc.client.ServerProxy.__init__(self, url, transport, allow_none=allow_none,
                                            verbose=verbose,
                                            **turn_off_server_verify)
 
     def __getattr__(self, attr):
         logger.debug("xml-rpc %s method:%s" % (self.url, attr))
-        return xmlrpc_client.ServerProxy.__getattr__(self, attr)
+        return xmlrpc.client.ServerProxy.__getattr__(self, attr)
 
 # the object on which we can send methods that get sent over xmlrpc
 
@@ -109,7 +109,7 @@ class SfaServerProxy:
         self.certfile = certfile
         self.verbose = verbose
         self.timeout = timeout
-        # an instance of xmlrpc_client.ServerProxy
+        # an instance of xmlrpc.client.ServerProxy
         transport = XMLRPCTransport(keyfile, certfile, timeout)
         self.serverproxy = XMLRPCServerProxy(
             url, transport, allow_none=True, verbose=verbose)
index ac2a553..bafabe8 100644 (file)
@@ -35,7 +35,7 @@ from sfa.util.config import Config
 from sfa.util.version import version_core
 from sfa.util.cache import Cache
 from sfa.util.printable import printable
-from sfa.util.py23 import StringIO
+from io import StringIO
 
 from sfa.storage.record import Record
 
index 9df5144..8d412ef 100644 (file)
@@ -2,10 +2,10 @@
 
 from datetime import datetime
 import time
-from sfa.util.py23 import xmlrpc_client
+import xmlrpc.client
 
 dummy_url = "http://localhost:8080"
-dummy_api = xmlrpc_client.ServerProxy(dummy_url)
+dummy_api = xmlrpc.client.ServerProxy(dummy_url)
 
 # Add a user:
 my_user_id = dummy_api.AddUser({'email': 'john.doe@test.net', 'user_name': 'john.doe', 'keys': [
index e330d28..d590ad1 100644 (file)
@@ -3,7 +3,7 @@ import socket
 from urllib.parse import urlparse
 
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import xmlrpc_client
+import xmlrpc.client
 
 
 class DummyShell:
@@ -21,7 +21,7 @@ class DummyShell:
 
     def __init__(self, config):
         url = config.SFA_DUMMY_URL
-        self.proxy = xmlrpc_client.ServerProxy(
+        self.proxy = xmlrpc.client.ServerProxy(
             url, verbose=False, allow_none=True)
 
     def __getattr__(self, name):
index 083ea9d..cb6b14c 100644 (file)
@@ -1,8 +1,5 @@
 from sfa.util.xrn import get_authority
 
-from sfa.util.py23 import StringType
-
-
 def get_peer(pldriver, hrn):
     # Because of myplc native federation,  we first need to determine if this
     # slice belongs to out local plc or a myplc peer. We will assume it
@@ -19,7 +16,7 @@ def get_peer(pldriver, hrn):
         {}, ['peer_id', 'peername', 'shortname', 'hrn_root'])
     for peer_record in peers:
         names = [name.lower() for name in list(peer_record.values())
-                 if isinstance(name, StringType)]
+                 if isinstance(name, str)]
         if site_authority in names:
             peer = peer_record['shortname']
 
index c0eaad7..6fb55de 100755 (executable)
@@ -6,7 +6,7 @@ from sfa.util.xrn import Xrn, urn_to_hrn
 from sfa.rspecs.rspec import RSpec
 from sfa.rspecs.version_manager import VersionManager
 
-from sfa.util.py23 import StringIO
+from io import StringIO
 
 xslt = '''<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" indent="no"/>
index b4daf42..ac83262 100644 (file)
@@ -4,7 +4,6 @@ import os
 from sfa.util.faults import InvalidRSpec, UnsupportedRSpecVersion
 from sfa.rspecs.version import RSpecVersion
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import StringType
 
 
 class VersionManager:
@@ -55,7 +54,7 @@ class VersionManager:
         if isinstance(version, dict):
             retval = self._get_version(version.get('type'), version.get(
                 'version'), version.get('content_type'))
-        elif isinstance(version, StringType):
+        elif isinstance(version, str):
             version_parts = version.split(' ')
             num_parts = len(version_parts)
             type = version_parts[0]
index 17a18e0..8d5c247 100644 (file)
@@ -8,7 +8,6 @@ from sfa.rspecs.elements.versions.pgv2Node import PGv2Node
 from sfa.rspecs.elements.versions.pgv2SliverType import PGv2SliverType
 from sfa.rspecs.elements.versions.pgv2Lease import PGv2Lease
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import StringType
 
 
 class PGv2(RSpecVersion):
@@ -213,7 +212,7 @@ class PGv2(RSpecVersion):
         """
         from sfa.rspecs.rspec import RSpec
         # just copy over all the child elements under the root element
-        if isinstance(in_rspec, StringType):
+        if isinstance(in_rspec, str):
             in_rspec = RSpec(in_rspec)
 
         nodes = in_rspec.version.get_nodes()
index d5c47bf..ae55c07 100644 (file)
@@ -21,7 +21,7 @@ from sfa.util.config import Config
 from sfa.util.cache import Cache
 from sfa.trust.certificate import Certificate
 from sfa.trust.trustedroots import TrustedRoots
-from sfa.util.py23 import xmlrpc_client
+import xmlrpc.client
 
 # don't hard code an api class anymore here
 from sfa.generic import Generic
@@ -207,7 +207,7 @@ class SecureXMLRPCServer(http.server.HTTPServer, xmlrpc.server.SimpleXMLRPCDispa
             # can't use format_exc() as it is not available in jython yet
             # (even in trunk).
             type, value, tb = sys.exc_info()
-            raise xmlrpc_client.Fault(1, ''.join(
+            raise xmlrpc.client.Fault(1, ''.join(
                 traceback.format_exception(type, value, tb)))
 
     # override this one from the python 2.7 code
index 54fb745..d89021d 100644 (file)
@@ -17,7 +17,7 @@ except ImportError:
 ####################
 from sfa.util.faults import SfaInvalidAPIMethod, SfaAPIError, SfaFault
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import xmlrpc_client
+import xmlrpc.client
 
 ####################
 # See "2.2 Characters" in the XML specification:
@@ -91,7 +91,7 @@ def xmlrpclib_dump(self, value, write):
 # You can't hide from me!
 # Note: not quite  sure if this will still cause
 # the expected behaviour under python3
-xmlrpc_client.Marshaller._Marshaller__dump = xmlrpclib_dump
+xmlrpc.client.Marshaller._Marshaller__dump = xmlrpclib_dump
 
 
 class XmlrpcApi:
@@ -145,9 +145,9 @@ class XmlrpcApi:
         """
         # Parse request into method name and arguments
         try:
-            interface = xmlrpc_client
+            interface = xmlrpc.client
             self.protocol = 'xmlrpc'
-            (args, method) = xmlrpc_client.loads(data)
+            (args, method) = xmlrpc.client.loads(data)
             if method in method_map:
                 method = method_map[method]
             methodresponse = True
@@ -185,7 +185,7 @@ class XmlrpcApi:
         if self.protocol == 'xmlrpc':
             if not isinstance(result, SfaFault):
                 result = (result,)
-            response = xmlrpc_client.dumps(
+            response = xmlrpc.client.dumps(
                 result, methodresponse=True, encoding=self.encoding, allow_none=1)
         elif self.protocol == 'soap':
             if isinstance(result, Exception):
index a2e3bd4..b46c702 100644 (file)
@@ -13,7 +13,6 @@ from sfa.storage.record import Record
 from sfa.util.sfalogging import logger
 from sfa.util.sfatime import utcparse, datetime_to_string
 from sfa.util.xml import XML
-from sfa.util.py23 import StringType
 
 from sfa.trust.gid import GID
 
@@ -105,7 +104,7 @@ class RegRecord(Base, AlchemyObj):
         if hrn:
             self.hrn = hrn
         if gid:
-            if isinstance(gid, StringType):
+            if isinstance(gid, str):
                 self.gid = gid
             else:
                 self.gid = gid.save_to_string(save_parents=True)
@@ -143,7 +142,7 @@ class RegRecord(Base, AlchemyObj):
     def validate_gid(self, key, gid):
         if gid is None:
             return
-        elif isinstance(gid, StringType):
+        elif isinstance(gid, str):
             return gid
         else:
             return gid.save_to_string(save_parents=True)
index 1545cac..bd9d3b5 100644 (file)
@@ -8,8 +8,6 @@
 from types import NoneType, IntType, LongType, FloatType, DictType, TupleType, ListType
 from sfa.util.faults import SfaAPIError
 
-from sfa.util.py23 import StringType
-
 
 class Parameter:
     """
@@ -94,7 +92,7 @@ def xmlrpc_type(arg):
         return "boolean"
     elif arg_type == FloatType:
         return "double"
-    elif issubclass(arg_type, StringType):
+    elif issubclass(arg_type, str):
         return "string"
     elif arg_type == ListType or arg_type == TupleType:
         return "array"
index ac391a1..b88b02a 100644 (file)
@@ -6,7 +6,6 @@ from sfa.util.xml import XML
 from sfa.trust.gid import GID
 
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import StringType
 
 
 class Record:
@@ -58,9 +57,9 @@ class Record:
     def load_from_dict(self, d):
         for (k, v) in d.items():
             # experimental
-            if isinstance(v, StringType) and v.lower() in ['true']:
+            if isinstance(v, str) and v.lower() in ['true']:
                 v = True
-            if isinstance(v, StringType) and v.lower() in ['false']:
+            if isinstance(v, str) and v.lower() in ['false']:
                 v = False
             setattr(self, k, v)
 
index 3534c00..51e8648 100644 (file)
@@ -29,7 +29,7 @@ from sfa.util.sfatime import SFATIME_FORMAT
 
 from xml.dom.minidom import Document, parseString
 
-from sfa.util.py23 import StringIO
+from io import StringIO
 
 HAVELXML = False
 try:
index b481bbd..e250c42 100644 (file)
@@ -8,7 +8,6 @@ from sfa.util.faults import InsufficientRights, MissingCallerGID, \
     ConnectionKeyGIDMismatch, SfaPermissionDenied, CredentialNotVerifiable, \
     Forbidden, BadArgs
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import StringType
 from sfa.util.config import Config
 from sfa.util.xrn import Xrn, get_authority
 
@@ -70,7 +69,7 @@ class Auth:
         def log_invalid_cred(cred, exception):
             if isinstance(cred, dict) and 'geni_value' in cred:
                 cred = cred['geni_value']
-            if not isinstance(cred, StringType):
+            if not isinstance(cred, str):
                 logger.info(
                     "{}: cannot validate credential {}"
                     .format(exception, cred))
index 8174226..d0d36d5 100644 (file)
@@ -57,8 +57,6 @@ import OpenSSL
 # M2Crypto is imported on the fly to minimize crashes
 # import M2Crypto
 
-from sfa.util.py23 import PY3
-
 from sfa.util.faults import (CertExpired, CertMissingParent,
                              CertNotSignedByParent)
 from sfa.util.sfalogging import logger
@@ -276,8 +274,7 @@ class Keypair:
     def get_m2_pubkey(self):
         import M2Crypto
         if not self.m2key:
-            self.m2key = M2Crypto.EVP.load_key_string(
-                self.as_pem().encode(encoding="utf-8"))
+            self.m2key = M2Crypto.EVP.load_key_string(self.as_pem())
         return self.m2key
 
     ##
@@ -475,7 +472,7 @@ class Certificate:
             return ""
         string = OpenSSL.crypto.dump_certificate(
             OpenSSL.crypto.FILETYPE_PEM, self.x509)
-        if PY3 and isinstance(string, bytes):
+        if isinstance(string, bytes):
             string = string.decode()
         if save_parents and self.parent:
             string = string + self.parent.save_to_string(save_parents)
@@ -492,7 +489,7 @@ class Certificate:
             f = filep
         else:
             f = open(filename, 'w')
-        if PY3 and isinstance(string, bytes):
+        if isinstance(string, bytes):
             string = string.decode()
         f.write(string)
         f.close()
index 307ed95..92c114e 100644 (file)
@@ -36,7 +36,7 @@ import datetime
 from tempfile import mkstemp
 from xml.dom.minidom import Document, parseString
 
-from sfa.util.py23 import PY3, StringType, StringIO
+from io import StringIO
 
 from xml.parsers.expat import ExpatError
 
@@ -276,7 +276,7 @@ class Credential(object):
         self.version = None
 
         if cred:
-            if isinstance(cred, StringType):
+            if isinstance(cred, str):
                 string = cred
                 self.type = Credential.SFA_CREDENTIAL_TYPE
                 self.version = '3'
@@ -293,7 +293,7 @@ class Credential(object):
                     str = infile.read()
 
             # if this is a legacy credential, write error and bail out
-            if isinstance(str, StringType) and str.strip().startswith("-----"):
+            if isinstance(str, str) and str.strip().startswith("-----"):
                 logger.error(
                     "Legacy credentials not supported any more "
                     "- giving up with {}..."
@@ -639,7 +639,7 @@ class Credential(object):
             f = filep
         else:
             f = open(filename, "w")
-        if PY3 and isinstance(self.xml, bytes):
+        if isinstance(self.xml, bytes):
             self.xml = self.xml.decode()
         f.write(self.xml)
         f.close()
@@ -647,7 +647,7 @@ class Credential(object):
     def save_to_string(self, save_parents=True):
         if not self.xml:
             self.encode()
-        if PY3 and isinstance(self.xml, bytes):
+        if isinstance(self.xml, bytes):
             self.xml = self.xml.decode()
         return self.xml
 
index 7387902..7450b4d 100644 (file)
 
 
 import uuid
+import xmlrpc.client
 
 from sfa.trust.certificate import Certificate
 
 from sfa.util.faults import GidInvalidParentHrn, GidParentHrn
 from sfa.util.xrn import hrn_to_urn, urn_to_hrn, hrn_authfor_hrn
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import xmlrpc_client
 
 ##
 # Create a new uuid. Returns the UUID as a string.
@@ -176,7 +176,7 @@ class GID(Certificate):
         dict = {}
         if data:
             if data.lower().startswith('uri:http://<params>'):
-                dict = xmlrpc_client.loads(data[11:])[0][0]
+                dict = xmlrpc.client.loads(data[11:])[0][0]
             else:
                 spl = data.split(', ')
                 for val in spl:
index 1401b64..0be88b8 100644 (file)
@@ -29,7 +29,7 @@
 from sfa.trust.certificate import Certificate
 from sfa.trust.gid import GID
 
-from sfa.util.py23 import xmlrpc_client
+import xmlrpc.client
 
 # Ticket is tuple:
 #   (gidCaller, gidObject, attributes, rspec, delegate)
@@ -102,13 +102,13 @@ class SfaTicket(Certificate):
         if self.gidObject:
             dict["gidObject"] = self.gidObject.save_to_string(
                 save_parents=True)
-        str = "URI:" + xmlrpc_client.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 = xmlrpc_client.loads(self.get_data()[4:])[0][0]
+            dict = xmlrpc.client.loads(self.get_data()[4:])[0][0]
         else:
             dict = {}
 
index 7019e3c..7afde6e 100644 (file)
@@ -40,7 +40,7 @@ from sfa.trust.abac_credential import ABACCredential, ABACElement
 from sfa.trust.credential_factory import CredentialFactory
 from sfa.trust.gid import GID
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import StringIO
+from io import StringIO
 
 # Routine to validate that a speaks-for credential
 # says what it claims to say:
index 67e81c4..04b2b2d 100644 (file)
@@ -8,7 +8,7 @@ import time
 #import tempfile
 from io import StringIO
 from sfa.util.xml import XML
-from sfa.util.py23 import ConfigParser
+import configparser
 
 default_config = \
     """
@@ -28,7 +28,7 @@ class Config:
     def __init__(self, config_file='/etc/sfa/sfa_config'):
         self._files = []
         self.config_path = os.path.dirname(config_file)
-        self.config = ConfigParser.ConfigParser()
+        self.config = configparser.ConfigParser()
         self.filename = config_file
         if not os.path.isfile(self.filename):
             self.create(self.filename)
@@ -56,7 +56,7 @@ DO NOT EDIT. This file was automatically generated at
         if filename:
             try:
                 self.config.read(filename)
-            except ConfigParser.MissingSectionHeaderError:
+            except configparser.MissingSectionHeaderError:
                 if filename.endswith('.xml'):
                     self.load_xml(filename)
                 else:
@@ -107,7 +107,7 @@ DO NOT EDIT. This file was automatically generated at
                 section_name = section.lower()
                 var_name = varname.replace(section_name, "")[1:]
         if strict and not self.config.has_option(section_name, var_name):
-            raise ConfigParser.NoOptionError(var_name, section_name)
+            raise configparser.NoOptionError(var_name, section_name)
         return (section_name, var_name)
 
     def set_attributes(self):
@@ -190,10 +190,10 @@ DO NOT EDIT. This file was automatically generated at
     @staticmethod
     def is_ini(config_file):
         try:
-            c = ConfigParser.ConfigParser()
+            c = configparser.ConfigParser()
             c.read(config_file)
             return True
-        except ConfigParser.MissingSectionHeaderError:
+        except configparser.MissingSectionHeaderError:
             return False
 
     def dump(self, sections=None):
index ea62bad..07ec10d 100644 (file)
 #
 
 from sfa.util.genicode import GENICODE
-from sfa.util.py23 import xmlrpc_client
+import xmlrpc.client
 
 
-class SfaFault(xmlrpc_client.Fault):
+class SfaFault(xmlrpc.client.Fault):
 
     def __init__(self, faultCode, faultString, extra=None):
         if extra:
             faultString += ": " + str(extra)
-        xmlrpc_client.Fault.__init__(self, faultCode, faultString)
+        xmlrpc.client.Fault.__init__(self, faultCode, faultString)
 
 
 class Forbidden(SfaFault):
@@ -360,11 +360,11 @@ class SliverDoesNotExist(SfaFault):
         return repr(self.value)
 
 
-class BadRequestHash(xmlrpc_client.Fault):
+class BadRequestHash(xmlrpc.client.Fault):
 
     def __init__(self, hash=None, extra=None):
         faultString = "bad request hash: " + str(hash)
-        xmlrpc_client.Fault.__init__(self, GENICODE.ERROR, faultString)
+        xmlrpc.client.Fault.__init__(self, GENICODE.ERROR, faultString)
 
 
 class MissingTrustedRoots(SfaFault):
index e99d55a..b3d7d1a 100644 (file)
@@ -8,7 +8,6 @@ from types import IntType, LongType
 import textwrap
 
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import StringType
 from sfa.util.faults import SfaFault, SfaInvalidAPIMethod, SfaInvalidArgumentCount, SfaInvalidArgument
 
 from sfa.storage.parameter import Parameter, Mixed, python_type, xmlrpc_type
@@ -239,7 +238,7 @@ class Method:
 
         # Strings are a special case. Accept either unicode or str
         # types if a string is expected.
-        if issubclass(expected_type, StringType) and isinstance(value, StringType):
+        if issubclass(expected_type, str) and isinstance(value, str):
             pass
 
         # Integers and long integers are also special types. Accept
@@ -254,7 +253,7 @@ class Method:
                                      name)
 
         # If a minimum or maximum (length, value) has been specified
-        if issubclass(expected_type, StringType):
+        if issubclass(expected_type, str):
             if min is not None and \
                len(value.encode(self.api.encoding)) < min:
                 raise SfaInvalidArgument(
diff --git a/sfa/util/py23.py b/sfa/util/py23.py
deleted file mode 100644 (file)
index cb2e1e2..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# our own simplistic replacement for six
-import sys
-PY3 = sys.version_info[0] == 3
-
-StringType = str
-from io import StringIO
-
-import xmlrpc.client as xmlrpc_client
-import http.client as http_client
-import configparser as ConfigParser
index 6793ad5..aab0663 100644 (file)
@@ -29,7 +29,6 @@ import calendar
 import re
 
 from sfa.util.sfalogging import logger
-from sfa.util.py23 import StringType
 
 SFATIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
 
@@ -59,7 +58,7 @@ For safety this can also handle inputs that are either timestamps, or datetimes
 
     # prepare the input for the checks below by
     # casting strings ('1327098335') to ints
-    if isinstance(input, StringType):
+    if isinstance(input, str):
         try:
             input = int(input)
         except ValueError:
@@ -75,7 +74,7 @@ For safety this can also handle inputs that are either timestamps, or datetimes
     if isinstance(input, datetime.datetime):
         #logger.info ("argument to utcparse already a datetime - doing nothing")
         return input
-    elif isinstance(input, StringType):
+    elif isinstance(input, str):
         t = dateutil.parser.parse(input)
         if t.utcoffset() is not None:
             t = t.utcoffset() + t.replace(tzinfo=None)
index d9e23d5..9f43b96 100755 (executable)
@@ -3,8 +3,7 @@ from lxml import etree
 from sfa.util.faults import InvalidXML
 from sfa.rspecs.elements.element import Element
 
-from sfa.util.py23 import StringType
-from sfa.util.py23 import StringIO
+from io import StringIO
 
 # helper functions to help build xpaths
 
@@ -174,7 +173,7 @@ class XML:
         self.namespaces = namespaces
         self.default_namespace = None
         self.schema = None
-        if isinstance(xml, StringType):
+        if isinstance(xml, str):
             self.parse_xml(xml)
         if isinstance(xml, XmlElement):
             self.root = xml
@@ -238,7 +237,7 @@ class XML:
                     if isinstance(val, dict):
                         child_element = etree.SubElement(element, key)
                         self.parse_dict(val, key, child_element)
-                    elif isinstance(val, StringType):
+                    elif isinstance(val, str):
                         child_element = etree.SubElement(
                             element, key).text = val
 
@@ -252,7 +251,7 @@ class XML:
         d = d.copy()
         # looks like iteritems won't stand side-effects
         for k in list(d.keys()):
-            if not isinstance(d[k], StringType):
+            if not isinstance(d[k], str):
                 del d[k]
 
         element.attrib.update(d)
index 3860e3c..8104b24 100644 (file)
@@ -1,6 +1,5 @@
 import os, time
 
-from sfa.util.py23 import StringType
 
 class Command:
     commandline_options = []
@@ -154,7 +153,7 @@ class Command:
 
         # Strings are a special case. Accept either unicode or str
         # types if a string is expected.
-        if issubclass(expected_type, StringType) and isinstance(value, StringType):
+        if issubclass(expected_type, str) and isinstance(value, str):
             pass
 
         # Integers and long integers are also special types. Accept
@@ -169,7 +168,7 @@ class Command:
                                      name)
 
         # If a minimum or maximum (length, value) has been specified
-        if issubclass(expected_type, StringType):
+        if issubclass(expected_type, str):
             if min is not None and \
                len(value.encode(self.api.encoding)) < min:
                 raise SfaInvalidArgument("%s must be at least %d bytes long" % (name, min))
index 1d00d27..39c64d3 100755 (executable)
@@ -1,6 +1,6 @@
 import unittest
 from sfa.trust.certificate import Certificate, Keypair
-from sfa.util.py23 import xmlrpc_client
+import xmlrpc.client
 
 class TestCert(unittest.TestCase):
    def setUp(self):
@@ -42,7 +42,7 @@ class TestCert(unittest.TestCase):
       # try something a bit more complicated, like an xmlrpc encoding of
       # some parameters
       cert = Certificate(subject="test")
-      data = xmlrpc_client.dumps((1, "foo", ["a", "b"], {"c": "d", "e": "f"}, True))
+      data = xmlrpc.client.dumps((1, "foo", ["a", "b"], {"c": "d", "e": "f"}, True))
       cert.set_data(data)
       self.assertEqual(cert.get_data(), data)