X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Ftrust%2Fcredential.py;h=f03e135a192952e18628952ea53a982835e6c36c;hb=30d9951e075d93127c3909dcb41be09b420b3525;hp=ae2cc8d209bec0cded9a562a988719ad60eedab7;hpb=fad16c7d54b658b37a9b42fbee47b0d4f51cb8ec;p=sfa.git diff --git a/sfa/trust/credential.py b/sfa/trust/credential.py index ae2cc8d2..f03e135a 100644 --- a/sfa/trust/credential.py +++ b/sfa/trust/credential.py @@ -30,12 +30,13 @@ from __future__ import print_function import os, os.path import subprocess -from types import StringTypes import datetime from StringIO import StringIO from tempfile import mkstemp from xml.dom.minidom import Document, parseString +from sfa.util.py23 import StringType + HAVELXML = False try: from lxml import etree @@ -191,7 +192,7 @@ class Signature(object): try: doc = parseString(self.xml) - except ExpatError,e: + except ExpatError as e: logger.log_exc ("Failed to parse credential, %s"%self.xml) raise sig = doc.getElementsByTagName("Signature")[0] @@ -285,7 +286,7 @@ class Credential(object): self.version = None if cred: - if isinstance(cred, StringTypes): + if isinstance(cred, StringType): string = cred self.type = Credential.SFA_CREDENTIAL_TYPE self.version = '3' @@ -301,7 +302,7 @@ class Credential(object): str = file(filename).read() # if this is a legacy credential, write error and bail out - if isinstance (str, StringTypes) and str.strip().startswith("-----"): + if isinstance (str, StringType) and str.strip().startswith("-----"): logger.error("Legacy credentials not supported any more - giving up with %s..."%str[:10]) return else: @@ -730,7 +731,7 @@ class Credential(object): doc = None try: doc = parseString(self.xml) - except ExpatError,e: + except ExpatError as e: raise CredentialNotVerifiable("Malformed credential") doc = parseString(self.xml) sigs = [] @@ -860,7 +861,7 @@ class Credential(object): # or non PEM files trusted_cert_objects.append(GID(filename=f)) ok_trusted_certs.append(f) - except Exception, exc: + except Exception as exc: logger.error("Failed to load trusted cert from %s: %r"%( f, exc)) trusted_certs = ok_trusted_certs