X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/e00a8f0217a79d25b655223c17cc2d4752c816a4..411c85fc8390af786b56022f7df1c4648f1a82d4:/plugins/proxy.py diff --git a/plugins/proxy.py b/plugins/proxy.py index 51364cb31..176203989 100755 --- a/plugins/proxy.py +++ b/plugins/proxy.py @@ -43,7 +43,10 @@ try: # Python 3 import xmlrpc.client as _xmlrpc_client except ImportError: # Python 2 import xmlrpclib as _xmlrpc_client -from SimpleXMLRPCServer import SimpleXMLRPCDispatcher +try: # Python 3 + import xmlrpc.server as _xmlrpc_server +except ImportError: # Python 2 + import SimpleXMLRPCServer as _xmlrpc_server class ParseError (Exception): @@ -66,15 +69,16 @@ class AlreadyImported (Exception): pass -class _IkiWikiExtPluginXMLRPCDispatcher(SimpleXMLRPCDispatcher): +class _IkiWikiExtPluginXMLRPCDispatcher(_xmlrpc_server.SimpleXMLRPCDispatcher): def __init__(self, allow_none=False, encoding=None): try: - SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding) + _xmlrpc_server.SimpleXMLRPCDispatcher.__init__( + self, allow_none, encoding) except TypeError: # see http://bugs.debian.org/470645 # python2.4 and before only took one argument - SimpleXMLRPCDispatcher.__init__(self) + _xmlrpc_server.SimpleXMLRPCDispatcher.__init__(self) def dispatch(self, method, params): return self._dispatch(method, params) @@ -152,7 +156,7 @@ class _IkiWikiExtPluginXMLRPCHandler(object): return ret def send_rpc(self, cmd, in_fd, out_fd, *args, **kwargs): - xml = _xmlrpc_client.dumps(sum(kwargs.iteritems(), args), cmd) + xml = _xmlrpc_client.dumps(sum(kwargs.items(), args), cmd) self._debug_fn("calling ikiwiki procedure `{}': [{}]".format(cmd, xml)) _IkiWikiExtPluginXMLRPCHandler._write(out_fd, xml) @@ -223,7 +227,7 @@ class IkiWikiProcedureProxy(object): yield i args = list(subst_none(args)) - kwargs = dict(zip(kwargs.keys(), list(subst_none(kwargs.itervalues())))) + kwargs = dict(zip(kwargs.keys(), list(subst_none(kwargs.values())))) ret = self._xmlrpc_handler.send_rpc(cmd, self._in_fd, self._out_fd, *args, **kwargs) if ret == IkiWikiProcedureProxy._IKIWIKI_NIL_SENTINEL: @@ -308,8 +312,8 @@ class IkiWikiProcedureProxy(object): except Exception as e: import traceback - self.error('uncaught exception: {}\n{}'.format( - e, traceback.format_exc(sys.exc_info()[2]))) + tb = traceback.format_exc() + self.error('uncaught exception: {}\n{}'.format(e, tb)) return def _importme(self):