From 5751be639a614b656c902d0aca51af7ae29d20a8 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Thu, 31 Mar 2016 09:49:49 +0200 Subject: [PATCH] xmlrpclib.Fault for py3 --- sfa/util/faults.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sfa/util/faults.py b/sfa/util/faults.py index 4a614b1d..7299f27d 100644 --- a/sfa/util/faults.py +++ b/sfa/util/faults.py @@ -24,14 +24,18 @@ # SFA API faults # -import xmlrpclib +try: + from xmlrpc.client import Fault as xmlrpcFault +except: + from xmlrpclib import Fault as xmlrpcFault + from sfa.util.genicode import GENICODE -class SfaFault(xmlrpclib.Fault): +class SfaFault(xmlrpcFault): def __init__(self, faultCode, faultString, extra = None): if extra: faultString += ": " + str(extra) - xmlrpclib.Fault.__init__(self, faultCode, faultString) + xmlrpcFault.__init__(self, faultCode, faultString) class Forbidden(SfaFault): def __init__(self, extra = None): @@ -272,10 +276,10 @@ class SliverDoesNotExist(SfaFault): def __str__(self): return repr(self.value) -class BadRequestHash(xmlrpclib.Fault): +class BadRequestHash(xmlrpcFault): def __init__(self, hash = None, extra = None): faultString = "bad request hash: " + str(hash) - xmlrpclib.Fault.__init__(self, GENICODE.ERROR, faultString) + xmlrpcFault.__init__(self, GENICODE.ERROR, faultString) class MissingTrustedRoots(SfaFault): def __init__(self, value, extra = None): -- 2.43.0