Skip to content

Commit 43832a8

Browse files
committed
Python 3 preparation: update xmlrpclib / SimpleXMLRPCServer imports.
New roundup/anypy/xmlrpc_.py added. Manual patch.
1 parent 68021a8 commit 43832a8

File tree

9 files changed

+32
-19
lines changed

9 files changed

+32
-19
lines changed

roundup/anypy/xmlrpc_.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
try:
2+
# Python 3+.
3+
from xmlrpc import client, server
4+
except ImportError:
5+
# Python 2.
6+
import xmlrpclib as client
7+
import SimpleXMLRPCServer as server

roundup/cgi/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
get_cookie_date
4343
from roundup.anypy import http_
4444
from roundup.anypy import urllib_
45+
from roundup.anypy import xmlrpc_
4546

4647
from email.MIMEBase import MIMEBase
4748
from email.MIMEText import MIMEText
4849
from email.MIMEMultipart import MIMEMultipart
4950
import roundup.anypy.email_
50-
import xmlrpclib
5151

5252
def initialiseSecurity(security):
5353
'''Create some Permissions and Roles on the security object
@@ -466,8 +466,8 @@ def handle_xmlrpc(self):
466466
except (Unauthorised, UsageError) as msg:
467467
# report exception back to server
468468
exc_type, exc_value, exc_tb = sys.exc_info()
469-
output = xmlrpclib.dumps(
470-
xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)),
469+
output = xmlrpc_.client.dumps(
470+
xmlrpc_.client.Fault(1, "%s:%s" % (exc_type, exc_value)),
471471
allow_none=True)
472472
csrf_ok = False # we had an error, failed check
473473

roundup/scripts/roundup_xmlrpc_server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
import roundup.instance
2828
from roundup.instance import TrackerError
2929
from roundup.cgi.exceptions import Unauthorised
30-
from SimpleXMLRPCServer import SimpleXMLRPCServer
31-
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
30+
from roundup.anypy import xmlrpc_
31+
SimpleXMLRPCServer = xmlrpc_.server.SimpleXMLRPCServer
32+
SimpleXMLRPCRequestHandler = xmlrpc_.server.SimpleXMLRPCRequestHandler
3233

3334

3435
class RequestHandler(SimpleXMLRPCRequestHandler):

roundup/xmlrpc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from roundup.exceptions import Unauthorised, UsageError
1010
from roundup.date import Date, Range, Interval
1111
from roundup import actions
12-
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
13-
from xmlrpclib import Binary
12+
from roundup.anypy import xmlrpc_
13+
SimpleXMLRPCDispatcher = xmlrpc_.server.SimpleXMLRPCDispatcher
14+
Binary = xmlrpc_.client.Binary
1415
from traceback import format_exc
1516

1617
def translate(value):

scripts/schema-dump.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import os
2020
import sys
21-
import xmlrpclib
21+
from roundup.anypy import xmlrpc_
2222
import pprint
2323
import textwrap
2424
from optparse import OptionParser
@@ -92,7 +92,7 @@ def format_yaml(var):
9292
(options, args) = parser.parse_args()
9393

9494
url = args[0]
95-
roundup_server = xmlrpclib.ServerProxy(url, allow_none=True)
95+
roundup_server = xmlrpc_.client.ServerProxy(url, allow_none=True)
9696
schema = roundup_server.schema()
9797
if options.raw:
9898
print(str(schema))

share/roundup/templates/devel/extensions/spambayes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import re, math
22
from roundup.cgi.actions import Action
33
from roundup.cgi.exceptions import *
4+
from roundup.anypy import xmlrpc_
45

5-
import xmlrpclib, socket
6+
import socket
67

78
REVPAT = re.compile(r'(r[0-9]+\b|rev(ision)? [0-9]+\b)')
89

@@ -26,11 +27,11 @@ def extract_classinfo(db, classname, nodeid):
2627
def train_spambayes(db, content, tokens, is_spam):
2728
spambayes_uri = db.config.detectors['SPAMBAYES_URI']
2829

29-
server = xmlrpclib.ServerProxy(spambayes_uri, verbose=False)
30+
server = xmlrpc_.client.ServerProxy(spambayes_uri, verbose=False)
3031
try:
3132
server.train({'content':content}, tokens, {}, is_spam)
3233
return (True, None)
33-
except (socket.error, xmlrpclib.Error) as e:
34+
except (socket.error, xmlrpc_.client.Error) as e:
3435
return (False, str(e))
3536

3637

share/roundup/templates/responsive/extensions/spambayes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import re, math
22
from roundup.cgi.actions import Action
33
from roundup.cgi.exceptions import *
4+
from roundup.anypy import xmlrpc_
45

5-
import xmlrpclib, socket
6+
import socket
67

78
REVPAT = re.compile(r'(r[0-9]+\b|rev(ision)? [0-9]+\b)')
89

@@ -26,11 +27,11 @@ def extract_classinfo(db, classname, nodeid):
2627
def train_spambayes(db, content, tokens, is_spam):
2728
spambayes_uri = db.config.detectors['SPAMBAYES_URI']
2829

29-
server = xmlrpclib.ServerProxy(spambayes_uri, verbose=False)
30+
server = xmlrpc_.client.ServerProxy(spambayes_uri, verbose=False)
3031
try:
3132
server.train({'content':content}, tokens, {}, is_spam)
3233
return (True, None)
33-
except (socket.error, xmlrpclib.Error) as e:
34+
except (socket.error, xmlrpc_.client.Error) as e:
3435
return (False, str(e))
3536

3637

test/test_xmlrpc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from __future__ import print_function
88
import unittest, os, shutil, errno, sys, difflib, cgi, re
99

10-
from xmlrpclib import MultiCall
10+
from roundup.anypy import xmlrpc_
11+
MultiCall = xmlrpc_.client.MultiCall
1112
from roundup.cgi.exceptions import *
1213
from roundup import init, instance, password, hyperdb, date
1314
from roundup.xmlrpc import RoundupInstance, RoundupDispatcher

website/issues/extensions/spambayes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import re, math
22
from roundup.cgi.actions import Action
33
from roundup.cgi.exceptions import *
4+
from roundup.anypy import xmlrpc_
45

5-
import xmlrpclib, socket
6+
import socket
67

78
REVPAT = re.compile(r'(r[0-9]+\b|rev(ision)? [0-9]+\b)')
89

@@ -26,11 +27,11 @@ def extract_classinfo(db, classname, nodeid):
2627
def train_spambayes(db, content, tokens, is_spam):
2728
spambayes_uri = db.config.detectors['SPAMBAYES_URI']
2829

29-
server = xmlrpclib.ServerProxy(spambayes_uri, verbose=False)
30+
server = xmlrpc_.client.ServerProxy(spambayes_uri, verbose=False)
3031
try:
3132
server.train({'content':content}, tokens, {}, is_spam)
3233
return (True, None)
33-
except (socket.error, xmlrpclib.Error) as e:
34+
except (socket.error, xmlrpc_.client.Error) as e:
3435
return (False, str(e))
3536

3637

0 commit comments

Comments
 (0)