3 from ApiExceptionCodes import *
5 VerboseExceptions = False
7 def EnableVerboseExceptions(x=True):
8 global VerboseExceptions
11 class ExceptionUnmarshaller(xmlrpclib.Unmarshaller):
14 return xmlrpclib.Unmarshaller.close(self)
\r
15 except xmlrpclib.Fault, e:
\r
16 # if the server tagged some traceback info onto the end of the
\r
17 # exception text, then print it out on the client.
\r
19 if "\nFAULT_TRACEBACK:" in e.faultString:
\r
20 parts = e.faultString.split("\nFAULT_TRACEBACK:")
\r
21 e.faultString = parts[0]
\r
22 if VerboseExceptions:
\r
23 print "\n|Server Traceback:", "\n|".join(parts[1].split("\n"))
\r
27 class ExceptionReportingTransport(xmlrpclib.Transport):
28 def make_connection(self, host):
30 if host.startswith("https:"):
\r
31 return httplib.HTTPS(host)
\r
33 return httplib.HTTP(host)
\r
35 def getparser(self):
\r
36 unmarshaller = ExceptionUnmarshaller()
\r
37 parser = xmlrpclib.ExpatParser(unmarshaller)
\r
38 return parser, unmarshaller
41 def __init__(self, url):
43 self.server = xmlrpclib.ServerProxy(self.url, ExceptionReportingTransport())
45 def noop(self, value):
46 return self.server.noop(value)