git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
prettified certificate, credential and speaksfor_util
[sfa.git]
/
sfa
/
util
/
faults.py
diff --git
a/sfa/util/faults.py
b/sfa/util/faults.py
index
e46b986
..
702b685
100644
(file)
--- a/
sfa/util/faults.py
+++ b/
sfa/util/faults.py
@@
-24,20
+24,26
@@
# SFA API faults
#
# SFA API faults
#
-import xmlrpclib
from sfa.util.genicode import GENICODE
from sfa.util.genicode import GENICODE
+from sfa.util.py23 import xmlrpc_client
-class SfaFault(xmlrpc
lib
.Fault):
+class SfaFault(xmlrpc
_client
.Fault):
def __init__(self, faultCode, faultString, extra = None):
if extra:
faultString += ": " + str(extra)
def __init__(self, faultCode, faultString, extra = None):
if extra:
faultString += ": " + str(extra)
- xmlrpc
lib
.Fault.__init__(self, faultCode, faultString)
+ xmlrpc
_client
.Fault.__init__(self, faultCode, faultString)
class Forbidden(SfaFault):
def __init__(self, extra = None):
class Forbidden(SfaFault):
def __init__(self, extra = None):
- faultString = "FORBIDDEN
:
"
+ faultString = "FORBIDDEN"
SfaFault.__init__(self, GENICODE.FORBIDDEN, faultString, extra)
SfaFault.__init__(self, GENICODE.FORBIDDEN, faultString, extra)
+class BadArgs(SfaFault):
+ def __init__(self, extra = None):
+ faultString = "BADARGS"
+ SfaFault.__init__(self, GENICODE.BADARGS, faultString, extra)
+
+
class CredentialMismatch(SfaFault):
def __init__(self, extra = None):
faultString = "Credential mismatch"
class CredentialMismatch(SfaFault):
def __init__(self, extra = None):
faultString = "Credential mismatch"
@@
-92,7
+98,7
@@
class SfaNotImplemented(SfaFault):
class SfaAPIError(SfaFault):
def __init__(self, extra = None):
class SfaAPIError(SfaFault):
def __init__(self, extra = None):
- faultString = "Internal API error"
+ faultString = "Internal
SFA
API error"
SfaFault.__init__(self, GENICODE.SERVERERROR, faultString, extra)
class MalformedHrnException(SfaFault):
SfaFault.__init__(self, GENICODE.SERVERERROR, faultString, extra)
class MalformedHrnException(SfaFault):
@@
-266,10
+272,10
@@
class SliverDoesNotExist(SfaFault):
def __str__(self):
return repr(self.value)
def __str__(self):
return repr(self.value)
-class BadRequestHash(xmlrpc
lib
.Fault):
+class BadRequestHash(xmlrpc
_client
.Fault):
def __init__(self, hash = None, extra = None):
faultString = "bad request hash: " + str(hash)
def __init__(self, hash = None, extra = None):
faultString = "bad request hash: " + str(hash)
- xmlrpc
lib
.Fault.__init__(self, GENICODE.ERROR, faultString)
+ xmlrpc
_client
.Fault.__init__(self, GENICODE.ERROR, faultString)
class MissingTrustedRoots(SfaFault):
def __init__(self, value, extra = None):
class MissingTrustedRoots(SfaFault):
def __init__(self, value, extra = None):
@@
-323,7
+329,7
@@
class InvalidXML(SfaFault):
def __init__(self, value, extra = None):
self.value = value
faultString = "Invalid XML Document: %(value)s" % locals()
def __init__(self, value, extra = None):
self.value = value
faultString = "Invalid XML Document: %(value)s" % locals()
- SfaFault.__init__(self, GENICODE.
ERROR
, faultString, extra)
+ SfaFault.__init__(self, GENICODE.
BADARGS
, faultString, extra)
def __str__(self):
return repr(self.value)
def __str__(self):
return repr(self.value)
@@
-335,10
+341,13
@@
class AccountNotEnabled(SfaFault):
return repr(self.value)
class CredentialNotVerifiable(SfaFault):
return repr(self.value)
class CredentialNotVerifiable(SfaFault):
- def __init__(self, value, extra = None):
+ def __init__(self, value
=None
, extra = None):
self.value = value
self.value = value
- faultString = "Unable to verify credential: %(value)s, " %locals()
- SfaFault.__init__(self, GENICODE.ERROR, faultString, extra)
+ faultString = "Unable to verify credential" %locals()
+ if value:
+ faultString += ": %s" % value
+ faultString += ", "
+ SfaFault.__init__(self, GENICODE.BADARGS, faultString, extra)
def __str__(self):
return repr(self.value)
def __str__(self):
return repr(self.value)