Merge ~cjwatson/launchpad:xmlrpc-client into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 56a8319ea2e867c303242ee96164d32ee2bdaa53
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:xmlrpc-client
Merge into: launchpad:master
Diff against target: 2349 lines (+277/-273)
58 files modified
lib/launchpad_loggerhead/app.py (+4/-4)
lib/lp/app/stories/basics/xx-opstats.txt (+3/-3)
lib/lp/bugs/doc/bugtracker-tokens.txt (+2/-2)
lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt (+1/-1)
lib/lp/bugs/doc/externalbugtracker-bugzilla.txt (+30/-30)
lib/lp/bugs/doc/malone-xmlrpc.txt (+3/-3)
lib/lp/bugs/externalbugtracker/bugzilla.py (+18/-18)
lib/lp/bugs/externalbugtracker/tests/test_bugzilla.py (+3/-3)
lib/lp/bugs/externalbugtracker/tests/test_xmlrpc.py (+2/-2)
lib/lp/bugs/externalbugtracker/trac.py (+7/-7)
lib/lp/bugs/externalbugtracker/xmlrpc.py (+4/-4)
lib/lp/bugs/scripts/checkwatches/core.py (+1/-1)
lib/lp/bugs/scripts/checkwatches/tests/test_core.py (+1/-1)
lib/lp/bugs/scripts/checkwatches/utilities.py (+1/-2)
lib/lp/bugs/stories/bugtracker/xx-bugtracker-handshake-tokens.txt (+2/-2)
lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt (+2/-2)
lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt (+2/-2)
lib/lp/bugs/tests/externalbugtracker-xmlrpc-transport.txt (+4/-4)
lib/lp/bugs/tests/externalbugtracker.py (+23/-23)
lib/lp/bugs/tests/trac-xmlrpc-transport.txt (+2/-2)
lib/lp/buildmaster/interactor.py (+1/-1)
lib/lp/buildmaster/tests/mock_slaves.py (+5/-5)
lib/lp/buildmaster/tests/test_interactor.py (+4/-4)
lib/lp/buildmaster/tests/test_manager.py (+5/-5)
lib/lp/code/doc/branch-xmlrpc.txt (+2/-2)
lib/lp/code/doc/xmlrpc-codeimport-scheduler.txt (+2/-2)
lib/lp/code/interfaces/codeimportscheduler.py (+2/-2)
lib/lp/code/xmlrpc/branch.py (+1/-1)
lib/lp/code/xmlrpc/codeimportscheduler.py (+2/-2)
lib/lp/code/xmlrpc/git.py (+10/-10)
lib/lp/code/xmlrpc/tests/test_branch.py (+2/-2)
lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py (+7/-6)
lib/lp/code/xmlrpc/tests/test_git.py (+5/-5)
lib/lp/codehosting/inmemory.py (+1/-1)
lib/lp/codehosting/tests/test_acceptance.py (+3/-3)
lib/lp/codehosting/vfs/branchfs.py (+4/-4)
lib/lp/codehosting/vfs/tests/test_branchfs.py (+2/-2)
lib/lp/registry/tests/mailinglists_helper.py (+3/-2)
lib/lp/registry/tests/test_mailinglistapi.py (+2/-2)
lib/lp/registry/tests/test_xmlrpc.py (+6/-6)
lib/lp/registry/xmlrpc/mailinglist.py (+2/-2)
lib/lp/services/authserver/tests/test_authserver.py (+3/-2)
lib/lp/services/features/__init__.py (+1/-1)
lib/lp/services/features/tests/test_xmlrpc.py (+3/-3)
lib/lp/services/librarianserver/db.py (+1/-1)
lib/lp/services/tests/test_timeout.py (+3/-5)
lib/lp/services/timeout.py (+1/-1)
lib/lp/services/twistedsupport/xmlrpc.py (+2/-2)
lib/lp/services/webapp/servers.py (+5/-5)
lib/lp/services/xmlrpc.py (+8/-8)
lib/lp/soyuz/model/livefsbuildbehaviour.py (+1/-1)
lib/lp/soyuz/wsgi/archiveauth.py (+3/-3)
lib/lp/testing/xmlrpc.py (+3/-3)
lib/lp/xmlrpc/application.py (+3/-2)
lib/lp/xmlrpc/configure.zcml (+36/-36)
lib/lp/xmlrpc/helpers.py (+2/-1)
lib/lp/xmlrpc/tests/test_private_xmlrpc.py (+8/-7)
lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py (+8/-7)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+411270@code.launchpad.net

Commit message

Import xmlrpc.client directly

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

I'll take a look throughout the day - will take some time, obviously :-)

Revision history for this message
Jürgen Gmach (jugmac00) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/launchpad_loggerhead/app.py b/lib/launchpad_loggerhead/app.py
index cf7e1e7..aa58d54 100644
--- a/lib/launchpad_loggerhead/app.py
+++ b/lib/launchpad_loggerhead/app.py
@@ -4,6 +4,7 @@
4import logging4import logging
5import os5import os
6import threading6import threading
7import xmlrpc.client
78
8from breezy import (9from breezy import (
9 errors,10 errors,
@@ -40,7 +41,6 @@ from paste.request import (
40 path_info_pop,41 path_info_pop,
41 )42 )
42import six43import six
43from six.moves import xmlrpc_client
44from six.moves.urllib.parse import (44from six.moves.urllib.parse import (
45 urlencode,45 urlencode,
46 urljoin,46 urljoin,
@@ -72,7 +72,7 @@ thread_locals = threading.local()
72def check_fault(fault, *fault_classes):72def check_fault(fault, *fault_classes):
73 """Check if 'fault's faultCode matches any of 'fault_classes'.73 """Check if 'fault's faultCode matches any of 'fault_classes'.
7474
75 :param fault: An instance of `xmlrpc_client.Fault`.75 :param fault: An instance of `xmlrpc.client.Fault`.
76 :param fault_classes: Any number of `LaunchpadFault` subclasses.76 :param fault_classes: Any number of `LaunchpadFault` subclasses.
77 """77 """
78 for cls in fault_classes:78 for cls in fault_classes:
@@ -98,7 +98,7 @@ class RootApp:
98 def get_branchfs(self):98 def get_branchfs(self):
99 t = getattr(thread_locals, 'branchfs', None)99 t = getattr(thread_locals, 'branchfs', None)
100 if t is None:100 if t is None:
101 thread_locals.branchfs = xmlrpc_client.ServerProxy(101 thread_locals.branchfs = xmlrpc.client.ServerProxy(
102 config.codehosting.codehosting_endpoint)102 config.codehosting.codehosting_endpoint)
103 return thread_locals.branchfs103 return thread_locals.branchfs
104104
@@ -221,7 +221,7 @@ class RootApp:
221 branchfs = self.get_branchfs()221 branchfs = self.get_branchfs()
222 transport_type, info, trail = branchfs.translatePath(222 transport_type, info, trail = branchfs.translatePath(
223 identity_url, urlutils.escape(path))223 identity_url, urlutils.escape(path))
224 except xmlrpc_client.Fault as f:224 except xmlrpc.client.Fault as f:
225 if check_fault(f, faults.PathTranslationError):225 if check_fault(f, faults.PathTranslationError):
226 raise HTTPNotFound()226 raise HTTPNotFound()
227 elif check_fault(f, faults.PermissionDenied):227 elif check_fault(f, faults.PermissionDenied):
diff --git a/lib/lp/app/stories/basics/xx-opstats.txt b/lib/lp/app/stories/basics/xx-opstats.txt
index 1539c53..09a1389 100644
--- a/lib/lp/app/stories/basics/xx-opstats.txt
+++ b/lib/lp/app/stories/basics/xx-opstats.txt
@@ -4,9 +4,9 @@ Operational Statistics and Metrics
4We make Zope 3 give us real time statistics about Launchpad's operation.4We make Zope 3 give us real time statistics about Launchpad's operation.
5We can access them via XML-RPC:5We can access them via XML-RPC:
66
7 >>> from six.moves import xmlrpc_client7 >>> import xmlrpc.client
8 >>> from lp.testing.xmlrpc import XMLRPCTestTransport8 >>> from lp.testing.xmlrpc import XMLRPCTestTransport
9 >>> lp_xmlrpc = xmlrpc_client.ServerProxy(9 >>> lp_xmlrpc = xmlrpc.client.ServerProxy(
10 ... 'http://xmlrpc.launchpad.test/+opstats',10 ... 'http://xmlrpc.launchpad.test/+opstats',
11 ... transport=XMLRPCTestTransport()11 ... transport=XMLRPCTestTransport()
12 ... )12 ... )
@@ -192,7 +192,7 @@ Number of XML-RPC Faults
192 ... try:192 ... try:
193 ... opstats = lp_xmlrpc.invalid() # XXX: Need a HTTP test too193 ... opstats = lp_xmlrpc.invalid() # XXX: Need a HTTP test too
194 ... print('Should have raised a Fault exception!')194 ... print('Should have raised a Fault exception!')
195 ... except xmlrpc_client.Fault:195 ... except xmlrpc.client.Fault:
196 ... pass196 ... pass
197 >>> report()197 >>> report()
198 requests: 1198 requests: 1
diff --git a/lib/lp/bugs/doc/bugtracker-tokens.txt b/lib/lp/bugs/doc/bugtracker-tokens.txt
index a32f050..0d5d6e8 100644
--- a/lib/lp/bugs/doc/bugtracker-tokens.txt
+++ b/lib/lp/bugs/doc/bugtracker-tokens.txt
@@ -3,12 +3,12 @@ Using BugTracker Login Tokens
33
4Launchpad offers an XML-RPC interface for generating bug tracker tokens.4Launchpad offers an XML-RPC interface for generating bug tracker tokens.
55
6 >>> from six.moves import xmlrpc_client6 >>> import xmlrpc.client
7 >>> from zope.component import getUtility7 >>> from zope.component import getUtility
8 >>> from lp.testing.xmlrpc import XMLRPCTestTransport8 >>> from lp.testing.xmlrpc import XMLRPCTestTransport
9 >>> from lp.services.verification.interfaces.logintoken import (9 >>> from lp.services.verification.interfaces.logintoken import (
10 ... ILoginTokenSet)10 ... ILoginTokenSet)
11 >>> bugtracker_api = xmlrpc_client.ServerProxy(11 >>> bugtracker_api = xmlrpc.client.ServerProxy(
12 ... 'http://xmlrpc-private.launchpad.test:8087/bugs',12 ... 'http://xmlrpc-private.launchpad.test:8087/bugs',
13 ... transport=XMLRPCTestTransport())13 ... transport=XMLRPCTestTransport())
1414
diff --git a/lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt b/lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt
index 218e38d..579ba33 100644
--- a/lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt
+++ b/lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt
@@ -130,7 +130,7 @@ login_required() and will retry the method call.
130130
131If authentication fails, a BugTrackerAuthenticationError will be raised.131If authentication fails, a BugTrackerAuthenticationError will be raised.
132132
133 >>> from six.moves.xmlrpc_client import Fault, ProtocolError133 >>> from xmlrpc.client import Fault, ProtocolError
134 >>> class TestAuthFailingBugzillaXMLRPCTransport(134 >>> class TestAuthFailingBugzillaXMLRPCTransport(
135 ... ZopelessBugzillaXMLRPCTransport):135 ... ZopelessBugzillaXMLRPCTransport):
136 ... error = Fault(100, "Sorry, you can't log in.")136 ... error = Fault(100, "Sorry, you can't log in.")
diff --git a/lib/lp/bugs/doc/externalbugtracker-bugzilla.txt b/lib/lp/bugs/doc/externalbugtracker-bugzilla.txt
index d04257a..7ecb403 100644
--- a/lib/lp/bugs/doc/externalbugtracker-bugzilla.txt
+++ b/lib/lp/bugs/doc/externalbugtracker-bugzilla.txt
@@ -86,25 +86,25 @@ ExternalBugTracker will be returned.
86The Bugzilla ExternalBugTracker has a _test_xmlrpc_proxy property which86The Bugzilla ExternalBugTracker has a _test_xmlrpc_proxy property which
87we override for the purpose of this test.87we override for the purpose of this test.
8888
89 >>> from six.moves import xmlrpc_client89 >>> import xmlrpc.client
90 >>> class FailingXMLRPCTransport(xmlrpc_client.Transport):90 >>> class FailingXMLRPCTransport(xmlrpc.client.Transport):
91 ...91 ...
92 ... error = xmlrpc_client.Fault(92 ... error = xmlrpc.client.Fault(
93 ... xmlrpc_client.METHOD_NOT_FOUND, "Method doesn't exist")93 ... xmlrpc.client.METHOD_NOT_FOUND, "Method doesn't exist")
94 ...94 ...
95 ... def request(self, host, handler, request, verbose=None):95 ... def request(self, host, handler, request, verbose=None):
96 ... if self.error is not None:96 ... if self.error is not None:
97 ... raise self.error97 ... raise self.error
98 ... else:98 ... else:
99 ... # We need to return something here, otherwise99 ... # We need to return something here, otherwise
100 ... # xmlrpc_client will explode.100 ... # xmlrpc.client will explode.
101 ... return '0.42-test'101 ... return '0.42-test'
102 ...102 ...
103 >>> test_transport = FailingXMLRPCTransport()103 >>> test_transport = FailingXMLRPCTransport()
104104
105 >>> class BugzillaWithFakeProxy(Bugzilla):105 >>> class BugzillaWithFakeProxy(Bugzilla):
106 ...106 ...
107 ... _test_xmlrpc_proxy = xmlrpc_client.ServerProxy(107 ... _test_xmlrpc_proxy = xmlrpc.client.ServerProxy(
108 ... 'http://example.com/xmlrpc.cgi', transport=test_transport)108 ... 'http://example.com/xmlrpc.cgi', transport=test_transport)
109109
110 >>> bugzilla = BugzillaWithFakeProxy('http://example.com')110 >>> bugzilla = BugzillaWithFakeProxy('http://example.com')
@@ -129,7 +129,7 @@ BugzillaAPI instance.
129The same is true if getExternalBugTrackerToUse() receives a 404 error129The same is true if getExternalBugTrackerToUse() receives a 404 error
130from the remote server.130from the remote server.
131131
132 >>> test_transport.error = xmlrpc_client.ProtocolError(132 >>> test_transport.error = xmlrpc.client.ProtocolError(
133 ... 'http://example.com/xmlrpc.cgi', 404, 'Not Found', None)133 ... 'http://example.com/xmlrpc.cgi', 404, 'Not Found', None)
134134
135 >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()135 >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()
@@ -141,7 +141,7 @@ from the remote server.
141Some Bugzillas respond to an invalid XML-RPC method call by returning a141Some Bugzillas respond to an invalid XML-RPC method call by returning a
142500 error. getExternalBugTrackerToUse() handles those, too.142500 error. getExternalBugTrackerToUse() handles those, too.
143143
144 >>> test_transport.error = xmlrpc_client.ProtocolError(144 >>> test_transport.error = xmlrpc.client.ProtocolError(
145 ... 'http://example.com/xmlrpc.cgi', 500, 'Server Error', None)145 ... 'http://example.com/xmlrpc.cgi', 500, 'Server Error', None)
146146
147 >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()147 >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()
@@ -153,7 +153,7 @@ Some Bugzillas respond to an invalid XML-RPC method call by returning a
153Some other Bugzillas generate an unparsable response, causing153Some other Bugzillas generate an unparsable response, causing
154ResponseError to be raised.154ResponseError to be raised.
155155
156 >>> test_transport.error = xmlrpc_client.ResponseError()156 >>> test_transport.error = xmlrpc.client.ResponseError()
157 >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()157 >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()
158158
159 >>> (isinstance(bugzilla_to_use, Bugzilla) and159 >>> (isinstance(bugzilla_to_use, Bugzilla) and
@@ -164,22 +164,22 @@ If the remote Bugzilla offers the Bugzilla 3.4 API, an instance of
164BuzillaAPI will be returned. To test this, we use a specially-crafted164BuzillaAPI will be returned. To test this, we use a specially-crafted
165XML-RPC proxy that behaves like a Bugzilla 3.4 instance.165XML-RPC proxy that behaves like a Bugzilla 3.4 instance.
166166
167 >>> class APIXMLRPCTransport(xmlrpc_client.Transport):167 >>> class APIXMLRPCTransport(xmlrpc.client.Transport):
168 ...168 ...
169 ... version = '3.4.2'169 ... version = '3.4.2'
170 ...170 ...
171 ... def request(self, host, handler, request, verbose=None):171 ... def request(self, host, handler, request, verbose=None):
172 ... args, method_name = xmlrpc_client.loads(request)172 ... args, method_name = xmlrpc.client.loads(request)
173 ...173 ...
174 ... if method_name == 'Bugzilla.version':174 ... if method_name == 'Bugzilla.version':
175 ... return [{'version': self.version}]175 ... return [{'version': self.version}]
176 ... else:176 ... else:
177 ... raise xmlrpc_client.Fault(177 ... raise xmlrpc.client.Fault(
178 ... xmlrpc_client.METHOD_NOT_FOUND, 'No such method')178 ... xmlrpc.client.METHOD_NOT_FOUND, 'No such method')
179 ...179 ...
180 >>> test_transport = APIXMLRPCTransport()180 >>> test_transport = APIXMLRPCTransport()
181181
182 >>> bugzilla._test_xmlrpc_proxy = xmlrpc_client.ServerProxy(182 >>> bugzilla._test_xmlrpc_proxy = xmlrpc.client.ServerProxy(
183 ... 'http://example.com/xmlrpc.cgi',183 ... 'http://example.com/xmlrpc.cgi',
184 ... transport=test_transport)184 ... transport=test_transport)
185185
@@ -193,7 +193,7 @@ A version older than 3.4 is not accepted.
193 >>> test_transport = APIXMLRPCTransport()193 >>> test_transport = APIXMLRPCTransport()
194 >>> test_transport.version = '3.3'194 >>> test_transport.version = '3.3'
195195
196 >>> bugzilla._test_xmlrpc_proxy = xmlrpc_client.ServerProxy(196 >>> bugzilla._test_xmlrpc_proxy = xmlrpc.client.ServerProxy(
197 ... 'http://example.com/xmlrpc.cgi',197 ... 'http://example.com/xmlrpc.cgi',
198 ... transport=test_transport)198 ... transport=test_transport)
199199
@@ -206,7 +206,7 @@ bugzilla.mozilla.org uses a date-based version scheme. This is accepted.
206 >>> test_transport = APIXMLRPCTransport()206 >>> test_transport = APIXMLRPCTransport()
207 >>> test_transport.version = '20181108.1'207 >>> test_transport.version = '20181108.1'
208208
209 >>> bugzilla._test_xmlrpc_proxy = xmlrpc_client.ServerProxy(209 >>> bugzilla._test_xmlrpc_proxy = xmlrpc.client.ServerProxy(
210 ... 'http://example.com/xmlrpc.cgi',210 ... 'http://example.com/xmlrpc.cgi',
211 ... transport=test_transport)211 ... transport=test_transport)
212212
@@ -218,20 +218,20 @@ bugzilla.mozilla.org uses a date-based version scheme. This is accepted.
218If the remote system has the Launchpad plugin installed, an218If the remote system has the Launchpad plugin installed, an
219getExternalBugTrackerToUse() will return a BugzillaLPPlugin instance.219getExternalBugTrackerToUse() will return a BugzillaLPPlugin instance.
220220
221 >>> class PluginXMLRPCTransport(xmlrpc_client.Transport):221 >>> class PluginXMLRPCTransport(xmlrpc.client.Transport):
222 ...222 ...
223 ... def request(self, host, handler, request, verbose=None):223 ... def request(self, host, handler, request, verbose=None):
224 ... args, method_name = xmlrpc_client.loads(request)224 ... args, method_name = xmlrpc.client.loads(request)
225 ...225 ...
226 ... if method_name == 'Launchpad.plugin_version':226 ... if method_name == 'Launchpad.plugin_version':
227 ... return [{'version': '0.2'}]227 ... return [{'version': '0.2'}]
228 ... else:228 ... else:
229 ... raise xmlrpc_client.Fault(229 ... raise xmlrpc.client.Fault(
230 ... xmlrpc_client.METHOD_NOT_FOUND, 'No such method')230 ... xmlrpc.client.METHOD_NOT_FOUND, 'No such method')
231 ...231 ...
232 >>> test_transport = PluginXMLRPCTransport()232 >>> test_transport = PluginXMLRPCTransport()
233233
234 >>> bugzilla._test_xmlrpc_proxy = xmlrpc_client.ServerProxy(234 >>> bugzilla._test_xmlrpc_proxy = xmlrpc.client.ServerProxy(
235 ... 'http://example.com/xmlrpc.cgi',235 ... 'http://example.com/xmlrpc.cgi',
236 ... transport=test_transport)236 ... transport=test_transport)
237237
@@ -244,19 +244,19 @@ in response to XML-RPC calls. When something other than a mapping is
244returned, the standard non-API non-plugin external bug tracker is244returned, the standard non-API non-plugin external bug tracker is
245selected.245selected.
246246
247 >>> class OldXMLRPCTransport(xmlrpc_client.Transport):247 >>> class OldXMLRPCTransport(xmlrpc.client.Transport):
248 ... def request(self, host, handler, request, verbose=None):248 ... def request(self, host, handler, request, verbose=None):
249 ... args, method_name = xmlrpc_client.loads(request)249 ... args, method_name = xmlrpc.client.loads(request)
250 ...250 ...
251 ... if method_name == 'Bugzilla.version':251 ... if method_name == 'Bugzilla.version':
252 ... return ('versionResponse', {'version': '3.2.5+'})252 ... return ('versionResponse', {'version': '3.2.5+'})
253 ... else:253 ... else:
254 ... raise xmlrpc_client.Fault(254 ... raise xmlrpc.client.Fault(
255 ... xmlrpc_client.METHOD_NOT_FOUND, 'No such method')255 ... xmlrpc.client.METHOD_NOT_FOUND, 'No such method')
256 ...256 ...
257 >>> test_transport = OldXMLRPCTransport()257 >>> test_transport = OldXMLRPCTransport()
258258
259 >>> bugzilla._test_xmlrpc_proxy = xmlrpc_client.ServerProxy(259 >>> bugzilla._test_xmlrpc_proxy = xmlrpc.client.ServerProxy(
260 ... 'http://example.com/xmlrpc.cgi',260 ... 'http://example.com/xmlrpc.cgi',
261 ... transport=test_transport)261 ... transport=test_transport)
262262
@@ -270,18 +270,18 @@ is not discovered over XML-RPC. It's not clear if this is an error in
270Bugzilla or in and XML-RPC library used by Bugzilla. In any case, we270Bugzilla or in and XML-RPC library used by Bugzilla. In any case, we
271recognize and treat it the same as METHOD_NOT_FOUND.271recognize and treat it the same as METHOD_NOT_FOUND.
272272
273 >>> class OldBrokenXMLRPCTransport(xmlrpc_client.Transport):273 >>> class OldBrokenXMLRPCTransport(xmlrpc.client.Transport):
274 ... def request(self, host, handler, request, verbose=None):274 ... def request(self, host, handler, request, verbose=None):
275 ... args, method_name = xmlrpc_client.loads(request)275 ... args, method_name = xmlrpc.client.loads(request)
276 ...276 ...
277 ... if method_name == 'Bugzilla.version':277 ... if method_name == 'Bugzilla.version':
278 ... return ('versionResponse', {'version': '3.2.5+'})278 ... return ('versionResponse', {'version': '3.2.5+'})
279 ... else:279 ... else:
280 ... raise xmlrpc_client.Fault('Client', 'No such method')280 ... raise xmlrpc.client.Fault('Client', 'No such method')
281 ...281 ...
282 >>> test_transport = OldBrokenXMLRPCTransport()282 >>> test_transport = OldBrokenXMLRPCTransport()
283283
284 >>> bugzilla._test_xmlrpc_proxy = xmlrpc_client.ServerProxy(284 >>> bugzilla._test_xmlrpc_proxy = xmlrpc.client.ServerProxy(
285 ... 'http://example.com/xmlrpc.cgi',285 ... 'http://example.com/xmlrpc.cgi',
286 ... transport=test_transport)286 ... transport=test_transport)
287287
diff --git a/lib/lp/bugs/doc/malone-xmlrpc.txt b/lib/lp/bugs/doc/malone-xmlrpc.txt
index 0be732d..4b5ee05 100644
--- a/lib/lp/bugs/doc/malone-xmlrpc.txt
+++ b/lib/lp/bugs/doc/malone-xmlrpc.txt
@@ -3,9 +3,9 @@ XML-RPC Integration with Malone
33
4Malone provides an XML-RPC interface for filing bugs.4Malone provides an XML-RPC interface for filing bugs.
55
6 >>> from six.moves import xmlrpc_client6 >>> import xmlrpc.client
7 >>> from lp.testing.xmlrpc import XMLRPCTestTransport7 >>> from lp.testing.xmlrpc import XMLRPCTestTransport
8 >>> filebug_api = xmlrpc_client.ServerProxy(8 >>> filebug_api = xmlrpc.client.ServerProxy(
9 ... 'http://test@canonical.com:test@xmlrpc.launchpad.test/bugs/',9 ... 'http://test@canonical.com:test@xmlrpc.launchpad.test/bugs/',
10 ... transport=XMLRPCTestTransport())10 ... transport=XMLRPCTestTransport())
1111
@@ -278,7 +278,7 @@ The LoginToken generated will be of the LoginTokenType BUGTRACKER.
278278
279These requests are all handled by the private xml-rpc server.279These requests are all handled by the private xml-rpc server.
280280
281 >>> bugtracker_api = xmlrpc_client.ServerProxy(281 >>> bugtracker_api = xmlrpc.client.ServerProxy(
282 ... 'http://xmlrpc-private.launchpad.test:8087/bugs',282 ... 'http://xmlrpc-private.launchpad.test:8087/bugs',
283 ... transport=XMLRPCTestTransport())283 ... transport=XMLRPCTestTransport())
284284
diff --git a/lib/lp/bugs/externalbugtracker/bugzilla.py b/lib/lp/bugs/externalbugtracker/bugzilla.py
index 5269ebc..7a84697 100644
--- a/lib/lp/bugs/externalbugtracker/bugzilla.py
+++ b/lib/lp/bugs/externalbugtracker/bugzilla.py
@@ -14,12 +14,12 @@ from email.utils import parseaddr
14from http.client import BadStatusLine14from http.client import BadStatusLine
15import re15import re
16import xml.parsers.expat16import xml.parsers.expat
17import xmlrpc.client
1718
18from defusedxml import minidom19from defusedxml import minidom
19import pytz20import pytz
20import requests21import requests
21import six22import six
22from six.moves import xmlrpc_client
23from zope.component import getUtility23from zope.component import getUtility
24from zope.interface import (24from zope.interface import (
25 alsoProvides,25 alsoProvides,
@@ -90,15 +90,15 @@ class Bugzilla(ExternalBugTracker):
90 # We try calling Bugzilla.version() on the remote90 # We try calling Bugzilla.version() on the remote
91 # server because it's the most lightweight method there is.91 # server because it's the most lightweight method there is.
92 remote_version = proxy.Bugzilla.version()92 remote_version = proxy.Bugzilla.version()
93 except xmlrpc_client.Fault as fault:93 except xmlrpc.client.Fault as fault:
94 # 'Client' is a hangover. Either Bugzilla or the Perl94 # 'Client' is a hangover. Either Bugzilla or the Perl
95 # XML-RPC lib in use returned it as faultCode. It's wrong,95 # XML-RPC lib in use returned it as faultCode. It's wrong,
96 # but it's known wrongness, so we recognize it here.96 # but it's known wrongness, so we recognize it here.
97 if fault.faultCode in (xmlrpc_client.METHOD_NOT_FOUND, 'Client'):97 if fault.faultCode in (xmlrpc.client.METHOD_NOT_FOUND, 'Client'):
98 return False98 return False
99 else:99 else:
100 raise100 raise
101 except xmlrpc_client.ProtocolError as error:101 except xmlrpc.client.ProtocolError as error:
102 # We catch 404s, which occur when xmlrpc.cgi doesn't exist102 # We catch 404s, which occur when xmlrpc.cgi doesn't exist
103 # on the remote server, and 500s, which sometimes occur when103 # on the remote server, and 500s, which sometimes occur when
104 # an invalid request is made to the remote server. We allow104 # an invalid request is made to the remote server. We allow
@@ -107,7 +107,7 @@ class Bugzilla(ExternalBugTracker):
107 return False107 return False
108 else:108 else:
109 raise109 raise
110 except (xmlrpc_client.ResponseError, xml.parsers.expat.ExpatError):110 except (xmlrpc.client.ResponseError, xml.parsers.expat.ExpatError):
111 # The server returned an unparsable response.111 # The server returned an unparsable response.
112 return False112 return False
113 else:113 else:
@@ -132,15 +132,15 @@ class Bugzilla(ExternalBugTracker):
132 # We try calling Launchpad.plugin_version() on the remote132 # We try calling Launchpad.plugin_version() on the remote
133 # server because it's the most lightweight method there is.133 # server because it's the most lightweight method there is.
134 proxy.Launchpad.plugin_version()134 proxy.Launchpad.plugin_version()
135 except xmlrpc_client.Fault as fault:135 except xmlrpc.client.Fault as fault:
136 # 'Client' is a hangover. Either Bugzilla or the Perl136 # 'Client' is a hangover. Either Bugzilla or the Perl
137 # XML-RPC lib in use returned it as faultCode. It's wrong,137 # XML-RPC lib in use returned it as faultCode. It's wrong,
138 # but it's known wrongness, so we recognize it here.138 # but it's known wrongness, so we recognize it here.
139 if fault.faultCode in (xmlrpc_client.METHOD_NOT_FOUND, 'Client'):139 if fault.faultCode in (xmlrpc.client.METHOD_NOT_FOUND, 'Client'):
140 return False140 return False
141 else:141 else:
142 raise142 raise
143 except xmlrpc_client.ProtocolError as error:143 except xmlrpc.client.ProtocolError as error:
144 # We catch 404s, which occur when xmlrpc.cgi doesn't exist144 # We catch 404s, which occur when xmlrpc.cgi doesn't exist
145 # on the remote server, and 500s, which sometimes occur when145 # on the remote server, and 500s, which sometimes occur when
146 # the Launchpad Plugin isn't installed. Everything else we146 # the Launchpad Plugin isn't installed. Everything else we
@@ -150,7 +150,7 @@ class Bugzilla(ExternalBugTracker):
150 return False150 return False
151 else:151 else:
152 raise152 raise
153 except (xmlrpc_client.ResponseError, xml.parsers.expat.ExpatError):153 except (xmlrpc.client.ResponseError, xml.parsers.expat.ExpatError):
154 # The server returned an unparsable response.154 # The server returned an unparsable response.
155 return False155 return False
156 else:156 else:
@@ -169,7 +169,7 @@ class Bugzilla(ExternalBugTracker):
169 return BugzillaLPPlugin(self.baseurl)169 return BugzillaLPPlugin(self.baseurl)
170 elif self._remoteSystemHasBugzillaAPI():170 elif self._remoteSystemHasBugzillaAPI():
171 return BugzillaAPI(self.baseurl)171 return BugzillaAPI(self.baseurl)
172 except (xmlrpc_client.ProtocolError, requests.RequestException,172 except (xmlrpc.client.ProtocolError, requests.RequestException,
173 BadStatusLine):173 BadStatusLine):
174 pass174 pass
175 return self175 return self
@@ -538,14 +538,14 @@ class Bugzilla(ExternalBugTracker):
538def needs_authentication(func):538def needs_authentication(func):
539 """Decorator for automatically authenticating if needed.539 """Decorator for automatically authenticating if needed.
540540
541 If an `xmlrpc_client.Fault` with error code 410 is raised by the541 If an `xmlrpc.client.Fault` with error code 410 is raised by the
542 function, we'll try to authenticate and call the function again.542 function, we'll try to authenticate and call the function again.
543 """543 """
544544
545 def decorator(self, *args, **kwargs):545 def decorator(self, *args, **kwargs):
546 try:546 try:
547 return func(self, *args, **kwargs)547 return func(self, *args, **kwargs)
548 except xmlrpc_client.Fault as fault:548 except xmlrpc.client.Fault as fault:
549 # Catch authentication errors only.549 # Catch authentication errors only.
550 if fault.faultCode != 410:550 if fault.faultCode != 410:
551 raise551 raise
@@ -587,8 +587,8 @@ class BugzillaAPI(Bugzilla):
587587
588 @property588 @property
589 def xmlrpc_proxy(self):589 def xmlrpc_proxy(self):
590 """Return an `xmlrpc_client.ServerProxy` to self.xmlrpc_endpoint."""590 """Return an `xmlrpc.client.ServerProxy` to self.xmlrpc_endpoint."""
591 return xmlrpc_client.ServerProxy(591 return xmlrpc.client.ServerProxy(
592 self.xmlrpc_endpoint, transport=self.xmlrpc_transport)592 self.xmlrpc_endpoint, transport=self.xmlrpc_transport)
593593
594 @property594 @property
@@ -622,7 +622,7 @@ class BugzillaAPI(Bugzilla):
622 """622 """
623 try:623 try:
624 self.xmlrpc_proxy.User.login(self.credentials)624 self.xmlrpc_proxy.User.login(self.credentials)
625 except xmlrpc_client.Fault as fault:625 except xmlrpc.client.Fault as fault:
626 raise BugTrackerAuthenticationError(626 raise BugTrackerAuthenticationError(
627 self.baseurl,627 self.baseurl,
628 "Fault %s: %s" % (fault.faultCode, fault.faultString))628 "Fault %s: %s" % (fault.faultCode, fault.faultString))
@@ -972,7 +972,7 @@ class BugzillaLPPlugin(BugzillaAPI):
972 Bugzilla_logincookie, which we can then use to re-authenticate972 Bugzilla_logincookie, which we can then use to re-authenticate
973 ourselves for each subsequent method call.973 ourselves for each subsequent method call.
974 """974 """
975 internal_xmlrpc_server = xmlrpc_client.ServerProxy(975 internal_xmlrpc_server = xmlrpc.client.ServerProxy(
976 config.checkwatches.xmlrpc_url,976 config.checkwatches.xmlrpc_url,
977 transport=self.internal_xmlrpc_transport)977 transport=self.internal_xmlrpc_transport)
978978
@@ -981,12 +981,12 @@ class BugzillaLPPlugin(BugzillaAPI):
981 try:981 try:
982 self.xmlrpc_proxy.Launchpad.login(982 self.xmlrpc_proxy.Launchpad.login(
983 {'token': token_text})983 {'token': token_text})
984 except xmlrpc_client.Fault as fault:984 except xmlrpc.client.Fault as fault:
985 message = 'XML-RPC Fault: %s "%s"' % (985 message = 'XML-RPC Fault: %s "%s"' % (
986 fault.faultCode, fault.faultString)986 fault.faultCode, fault.faultString)
987 raise BugTrackerAuthenticationError(987 raise BugTrackerAuthenticationError(
988 self.baseurl, message)988 self.baseurl, message)
989 except xmlrpc_client.ProtocolError as error:989 except xmlrpc.client.ProtocolError as error:
990 message = 'Protocol error: %s "%s"' % (990 message = 'Protocol error: %s "%s"' % (
991 error.errcode, error.errmsg)991 error.errcode, error.errmsg)
992 raise BugTrackerAuthenticationError(992 raise BugTrackerAuthenticationError(
diff --git a/lib/lp/bugs/externalbugtracker/tests/test_bugzilla.py b/lib/lp/bugs/externalbugtracker/tests/test_bugzilla.py
index 2b8ea61..05bca65 100644
--- a/lib/lp/bugs/externalbugtracker/tests/test_bugzilla.py
+++ b/lib/lp/bugs/externalbugtracker/tests/test_bugzilla.py
@@ -4,9 +4,9 @@
4"""Tests for the Bugzilla BugTracker."""4"""Tests for the Bugzilla BugTracker."""
55
6from xml.parsers.expat import ExpatError6from xml.parsers.expat import ExpatError
7import xmlrpc.client
78
8import responses9import responses
9from six.moves import xmlrpc_client
10import transaction10import transaction
1111
12from lp.bugs.externalbugtracker.base import UnparsableBugData12from lp.bugs.externalbugtracker.base import UnparsableBugData
@@ -71,11 +71,11 @@ class TestBugzillaSniffing(TestCase):
71 # it is taken to mean that no XML-RPC capabilities exist.71 # it is taken to mean that no XML-RPC capabilities exist.
72 bugzilla = Bugzilla("http://not.real")72 bugzilla = Bugzilla("http://not.real")
7373
74 class Transport(xmlrpc_client.Transport):74 class Transport(xmlrpc.client.Transport):
75 def request(self, host, handler, request, verbose=None):75 def request(self, host, handler, request, verbose=None):
76 raise ExpatError("mismatched tag")76 raise ExpatError("mismatched tag")
7777
78 bugzilla._test_xmlrpc_proxy = xmlrpc_client.ServerProxy(78 bugzilla._test_xmlrpc_proxy = xmlrpc.client.ServerProxy(
79 '%s/xmlrpc.cgi' % bugzilla.baseurl, transport=Transport())79 '%s/xmlrpc.cgi' % bugzilla.baseurl, transport=Transport())
8080
81 # We must abort any existing transactions before attempting to call81 # We must abort any existing transactions before attempting to call
diff --git a/lib/lp/bugs/externalbugtracker/tests/test_xmlrpc.py b/lib/lp/bugs/externalbugtracker/tests/test_xmlrpc.py
index b23cbe5..c473f34 100644
--- a/lib/lp/bugs/externalbugtracker/tests/test_xmlrpc.py
+++ b/lib/lp/bugs/externalbugtracker/tests/test_xmlrpc.py
@@ -20,7 +20,7 @@ class TestRequestsTransport(TestCase):
2020
21 @responses.activate21 @responses.activate
22 def test_expat_error(self):22 def test_expat_error(self):
23 # Malformed XML-RPC responses cause xmlrpc_client to raise an23 # Malformed XML-RPC responses cause xmlrpc.client to raise an
24 # ExpatError.24 # ExpatError.
25 responses.add(25 responses.add(
26 "POST", "http://www.example.com/xmlrpc",26 "POST", "http://www.example.com/xmlrpc",
@@ -28,7 +28,7 @@ class TestRequestsTransport(TestCase):
28 transport = RequestsTransport("http://not.real/")28 transport = RequestsTransport("http://not.real/")
2929
30 # The Launchpad production environment selects Expat at present. This30 # The Launchpad production environment selects Expat at present. This
31 # is quite strict compared to the other parsers that xmlrpc_client31 # is quite strict compared to the other parsers that xmlrpc.client
32 # can possibly select.32 # can possibly select.
33 ensure_response_parser_is_expat(transport)33 ensure_response_parser_is_expat(transport)
3434
diff --git a/lib/lp/bugs/externalbugtracker/trac.py b/lib/lp/bugs/externalbugtracker/trac.py
index 9a2e0a3..9d67e1f 100644
--- a/lib/lp/bugs/externalbugtracker/trac.py
+++ b/lib/lp/bugs/externalbugtracker/trac.py
@@ -10,11 +10,11 @@ import csv
10from datetime import datetime10from datetime import datetime
11from email.utils import parseaddr11from email.utils import parseaddr
12import time12import time
13import xmlrpc.client
1314
14import pytz15import pytz
15import requests16import requests
16from requests.cookies import RequestsCookieJar17from requests.cookies import RequestsCookieJar
17from six.moves import xmlrpc_client
18from zope.component import getUtility18from zope.component import getUtility
19from zope.interface import implementer19from zope.interface import implementer
2020
@@ -305,14 +305,14 @@ class Trac(ExternalBugTracker):
305def needs_authentication(func):305def needs_authentication(func):
306 """Decorator for automatically authenticating if needed.306 """Decorator for automatically authenticating if needed.
307307
308 If an `xmlrpc_client.ProtocolError` with error code 403 is raised by the308 If an `xmlrpc.client.ProtocolError` with error code 403 is raised by the
309 function, we'll try to authenticate and call the function again.309 function, we'll try to authenticate and call the function again.
310 """310 """
311311
312 def decorator(self, *args, **kwargs):312 def decorator(self, *args, **kwargs):
313 try:313 try:
314 return func(self, *args, **kwargs)314 return func(self, *args, **kwargs)
315 except xmlrpc_client.ProtocolError as error:315 except xmlrpc.client.ProtocolError as error:
316 # Catch authentication errors only.316 # Catch authentication errors only.
317 if error.errcode != 403:317 if error.errcode != 403:
318 raise318 raise
@@ -340,7 +340,7 @@ class TracLPPlugin(Trac):
340 self._internal_xmlrpc_transport = internal_xmlrpc_transport340 self._internal_xmlrpc_transport = internal_xmlrpc_transport
341341
342 xmlrpc_endpoint = urlappend(self.baseurl, 'xmlrpc')342 xmlrpc_endpoint = urlappend(self.baseurl, 'xmlrpc')
343 self._server = xmlrpc_client.ServerProxy(343 self._server = xmlrpc.client.ServerProxy(
344 xmlrpc_endpoint, transport=self._xmlrpc_transport)344 xmlrpc_endpoint, transport=self._xmlrpc_transport)
345345
346 def makeRequest(self, method, url, **kwargs):346 def makeRequest(self, method, url, **kwargs):
@@ -365,7 +365,7 @@ class TracLPPlugin(Trac):
365 @ensure_no_transaction365 @ensure_no_transaction
366 def _generateAuthenticationToken(self):366 def _generateAuthenticationToken(self):
367 """Create an authentication token and return it."""367 """Create an authentication token and return it."""
368 internal_xmlrpc = xmlrpc_client.ServerProxy(368 internal_xmlrpc = xmlrpc.client.ServerProxy(
369 config.checkwatches.xmlrpc_url,369 config.checkwatches.xmlrpc_url,
370 transport=self._internal_xmlrpc_transport)370 transport=self._internal_xmlrpc_transport)
371 return internal_xmlrpc.newBugTrackerToken()371 return internal_xmlrpc.newBugTrackerToken()
@@ -491,7 +491,7 @@ class TracLPPlugin(Trac):
491 try:491 try:
492 timestamp, lp_bug_id = self._server.launchpad.get_launchpad_bug(492 timestamp, lp_bug_id = self._server.launchpad.get_launchpad_bug(
493 remote_bug)493 remote_bug)
494 except xmlrpc_client.Fault as fault:494 except xmlrpc.client.Fault as fault:
495 # Deal with "Ticket does not exist" faults. We re-raise495 # Deal with "Ticket does not exist" faults. We re-raise
496 # anything else, since they're a sign of a bigger problem.496 # anything else, since they're a sign of a bigger problem.
497 if fault.faultCode == FAULT_TICKET_NOT_FOUND:497 if fault.faultCode == FAULT_TICKET_NOT_FOUND:
@@ -522,7 +522,7 @@ class TracLPPlugin(Trac):
522 try:522 try:
523 self._server.launchpad.set_launchpad_bug(523 self._server.launchpad.set_launchpad_bug(
524 remote_bug, launchpad_bug_id)524 remote_bug, launchpad_bug_id)
525 except xmlrpc_client.Fault as fault:525 except xmlrpc.client.Fault as fault:
526 # Deal with "Ticket does not exist" faults. We re-raise526 # Deal with "Ticket does not exist" faults. We re-raise
527 # anything else, since they're a sign of a bigger problem.527 # anything else, since they're a sign of a bigger problem.
528 if fault.faultCode == FAULT_TICKET_NOT_FOUND:528 if fault.faultCode == FAULT_TICKET_NOT_FOUND:
diff --git a/lib/lp/bugs/externalbugtracker/xmlrpc.py b/lib/lp/bugs/externalbugtracker/xmlrpc.py
index b263982..6d63fe9 100644
--- a/lib/lp/bugs/externalbugtracker/xmlrpc.py
+++ b/lib/lp/bugs/externalbugtracker/xmlrpc.py
@@ -9,6 +9,10 @@ __all__ = [
99
1010
11from io import BytesIO11from io import BytesIO
12from xmlrpc.client import (
13 ProtocolError,
14 Transport,
15 )
1216
13from defusedxml.xmlrpc import monkey_patch17from defusedxml.xmlrpc import monkey_patch
14import requests18import requests
@@ -18,10 +22,6 @@ from six.moves.urllib.parse import (
18 urlparse,22 urlparse,
19 urlunparse,23 urlunparse,
20 )24 )
21from six.moves.xmlrpc_client import (
22 ProtocolError,
23 Transport,
24 )
2525
26from lp.bugs.externalbugtracker.base import repost_on_redirect_hook26from lp.bugs.externalbugtracker.base import repost_on_redirect_hook
27from lp.services.config import config27from lp.services.config import config
diff --git a/lib/lp/bugs/scripts/checkwatches/core.py b/lib/lp/bugs/scripts/checkwatches/core.py
index 3540182..c659a77 100644
--- a/lib/lp/bugs/scripts/checkwatches/core.py
+++ b/lib/lp/bugs/scripts/checkwatches/core.py
@@ -27,10 +27,10 @@ import socket
27import sys27import sys
28import threading28import threading
29import time29import time
30from xmlrpc.client import ProtocolError
3031
31import pytz32import pytz
32import six33import six
33from six.moves.xmlrpc_client import ProtocolError
34from twisted.internet import reactor34from twisted.internet import reactor
35from twisted.internet.defer import DeferredList35from twisted.internet.defer import DeferredList
36from twisted.internet.threads import deferToThreadPool36from twisted.internet.threads import deferToThreadPool
diff --git a/lib/lp/bugs/scripts/checkwatches/tests/test_core.py b/lib/lp/bugs/scripts/checkwatches/tests/test_core.py
index 27be1c9..f127aff 100644
--- a/lib/lp/bugs/scripts/checkwatches/tests/test_core.py
+++ b/lib/lp/bugs/scripts/checkwatches/tests/test_core.py
@@ -5,8 +5,8 @@
5from datetime import datetime5from datetime import datetime
6import threading6import threading
7import unittest7import unittest
8from xmlrpc.client import ProtocolError
89
9from six.moves.xmlrpc_client import ProtocolError
10import transaction10import transaction
11from zope.component import getUtility11from zope.component import getUtility
1212
diff --git a/lib/lp/bugs/scripts/checkwatches/utilities.py b/lib/lp/bugs/scripts/checkwatches/utilities.py
index c06207e..9c7ac94 100644
--- a/lib/lp/bugs/scripts/checkwatches/utilities.py
+++ b/lib/lp/bugs/scripts/checkwatches/utilities.py
@@ -9,8 +9,7 @@ __all__ = [
9 ]9 ]
1010
11import socket11import socket
1212from xmlrpc.client import ProtocolError
13from six.moves.xmlrpc_client import ProtocolError
1413
15from lp.bugs.externalbugtracker import (14from lp.bugs.externalbugtracker import (
16 BugNotFound,15 BugNotFound,
diff --git a/lib/lp/bugs/stories/bugtracker/xx-bugtracker-handshake-tokens.txt b/lib/lp/bugs/stories/bugtracker/xx-bugtracker-handshake-tokens.txt
index 7d7561c..abab32e 100644
--- a/lib/lp/bugs/stories/bugtracker/xx-bugtracker-handshake-tokens.txt
+++ b/lib/lp/bugs/stories/bugtracker/xx-bugtracker-handshake-tokens.txt
@@ -5,9 +5,9 @@ Launchpad can generate LoginTokens which can then be used to
5authenticate it with remote bug trackers. Generating these tokens is5authenticate it with remote bug trackers. Generating these tokens is
6done using the internal XML-RPC service.6done using the internal XML-RPC service.
77
8 >>> from six.moves import xmlrpc_client8 >>> import xmlrpc.client
9 >>> from lp.testing.xmlrpc import XMLRPCTestTransport9 >>> from lp.testing.xmlrpc import XMLRPCTestTransport
10 >>> bugtracker_api = xmlrpc_client.ServerProxy(10 >>> bugtracker_api = xmlrpc.client.ServerProxy(
11 ... 'http://xmlrpc-private.launchpad.test:8087/bugs',11 ... 'http://xmlrpc-private.launchpad.test:8087/bugs',
12 ... transport=XMLRPCTestTransport())12 ... transport=XMLRPCTestTransport())
1313
diff --git a/lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt b/lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt
index a22d598..185139b 100644
--- a/lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt
+++ b/lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt
@@ -9,12 +9,12 @@ very similar to the TestBugzillaXMLRPCTransport, which it subclasses.
9Only the parts of TestBugzillaAPIXMLRPCTransport that are different from9Only the parts of TestBugzillaAPIXMLRPCTransport that are different from
10its ancestor will be tested here.10its ancestor will be tested here.
1111
12 >>> from six.moves import xmlrpc_client12 >>> import xmlrpc.client
13 >>> from lp.bugs.tests.externalbugtracker import (13 >>> from lp.bugs.tests.externalbugtracker import (
14 ... TestBugzillaAPIXMLRPCTransport)14 ... TestBugzillaAPIXMLRPCTransport)
15 >>> bugzilla_transport = TestBugzillaAPIXMLRPCTransport(15 >>> bugzilla_transport = TestBugzillaAPIXMLRPCTransport(
16 ... 'http://example.com/xmlrpc.cgi')16 ... 'http://example.com/xmlrpc.cgi')
17 >>> server = xmlrpc_client.ServerProxy(17 >>> server = xmlrpc.client.ServerProxy(
18 ... 'http://example.com/xmlrpc.cgi', transport=bugzilla_transport)18 ... 'http://example.com/xmlrpc.cgi', transport=bugzilla_transport)
1919
2020
diff --git a/lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt b/lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt
index 445dbc6..d0e385e 100644
--- a/lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt
+++ b/lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt
@@ -4,12 +4,12 @@ TestBugzillaXMLRPCTransport
4The TestBugzillaXMLRPCTransport is an XML-RPC transport which simulates4The TestBugzillaXMLRPCTransport is an XML-RPC transport which simulates
5a remote Bugzilla instance that implements the Launchpad plugin API.5a remote Bugzilla instance that implements the Launchpad plugin API.
66
7 >>> from six.moves import xmlrpc_client7 >>> import xmlrpc.client
8 >>> from lp.bugs.tests.externalbugtracker import (8 >>> from lp.bugs.tests.externalbugtracker import (
9 ... TestBugzillaXMLRPCTransport)9 ... TestBugzillaXMLRPCTransport)
10 >>> bugzilla_transport = TestBugzillaXMLRPCTransport(10 >>> bugzilla_transport = TestBugzillaXMLRPCTransport(
11 ... 'http://example.com/xmlrpc.cgi')11 ... 'http://example.com/xmlrpc.cgi')
12 >>> server = xmlrpc_client.ServerProxy(12 >>> server = xmlrpc.client.ServerProxy(
13 ... 'http://example.com/xmlrpc.cgi', transport=bugzilla_transport)13 ... 'http://example.com/xmlrpc.cgi', transport=bugzilla_transport)
1414
15The test transport will only allow calls to methods in a predefined set15The test transport will only allow calls to methods in a predefined set
diff --git a/lib/lp/bugs/tests/externalbugtracker-xmlrpc-transport.txt b/lib/lp/bugs/tests/externalbugtracker-xmlrpc-transport.txt
index 79fa0b0..de54f39 100644
--- a/lib/lp/bugs/tests/externalbugtracker-xmlrpc-transport.txt
+++ b/lib/lp/bugs/tests/externalbugtracker-xmlrpc-transport.txt
@@ -22,13 +22,13 @@ request parameters as an XMLRPC parameter, and sets a cookie from the
22server, 'foo=bar'.22server, 'foo=bar'.
2323
24 >>> import responses24 >>> import responses
25 >>> from six.moves import xmlrpc_client25 >>> import xmlrpc.client
2626
27 >>> def test_callback(request):27 >>> def test_callback(request):
28 ... params = xmlrpc_client.loads(request.body)[0]28 ... params = xmlrpc.client.loads(request.body)[0]
29 ... return (29 ... return (
30 ... 200, {'Set-Cookie': 'foo=bar'},30 ... 200, {'Set-Cookie': 'foo=bar'},
31 ... xmlrpc_client.dumps(31 ... xmlrpc.client.dumps(
32 ... ([request.url] + list(params),), methodresponse=True))32 ... ([request.url] + list(params),), methodresponse=True))
3333
34Before sending the request, the transport's cookie jar is empty.34Before sending the request, the transport's cookie jar is empty.
@@ -71,7 +71,7 @@ In addition to cookies sent by the server, we can set cookies locally.
71 foo=bar71 foo=bar
7272
73If an error occurs trying to make the request, an73If an error occurs trying to make the request, an
74``xmlrpc_client.ProtocolError`` is raised.74``xmlrpc.client.ProtocolError`` is raised.
7575
76 >>> request_body = """<?xml version="1.0"?>76 >>> request_body = """<?xml version="1.0"?>
77 ... <methodCall>77 ... <methodCall>
diff --git a/lib/lp/bugs/tests/externalbugtracker.py b/lib/lp/bugs/tests/externalbugtracker.py
index a6b3ea4..cdce45f 100644
--- a/lib/lp/bugs/tests/externalbugtracker.py
+++ b/lib/lp/bugs/tests/externalbugtracker.py
@@ -14,10 +14,10 @@ import os
14import random14import random
15import re15import re
16import time16import time
17import xmlrpc.client
1718
18import responses19import responses
19import six20import six
20from six.moves import xmlrpc_client
21from six.moves.urllib_parse import (21from six.moves.urllib_parse import (
22 parse_qs,22 parse_qs,
23 urljoin,23 urljoin,
@@ -564,7 +564,7 @@ class TestBugzillaXMLRPCTransport(RequestsTransport):
564 method on this class with the same name as the XML-RPC method is564 method on this class with the same name as the XML-RPC method is
565 called, with the extracted arguments passed on to it.565 called, with the extracted arguments passed on to it.
566 """566 """
567 args, method_name = xmlrpc_client.loads(request)567 args, method_name = xmlrpc.client.loads(request)
568 method_prefix, method_name = method_name.split('.')568 method_prefix, method_name = method_name.split('.')
569569
570 assert method_prefix in self.methods, (570 assert method_prefix in self.methods, (
@@ -579,7 +579,7 @@ class TestBugzillaXMLRPCTransport(RequestsTransport):
579 # cookie, throw a Fault.579 # cookie, throw a Fault.
580 if (method_name in self.auth_required_methods and580 if (method_name in self.auth_required_methods and
581 not self.has_valid_auth_cookie):581 not self.has_valid_auth_cookie):
582 raise xmlrpc_client.Fault(410, 'Login Required')582 raise xmlrpc.client.Fault(410, 'Login Required')
583583
584 if self.print_method_calls:584 if self.print_method_calls:
585 if len(args) > 0:585 if len(args) > 0:
@@ -638,7 +638,7 @@ class TestBugzillaXMLRPCTransport(RequestsTransport):
638 self._setAuthCookie()638 self._setAuthCookie()
639639
640 # We always return the same user ID.640 # We always return the same user ID.
641 # This has to be listified because xmlrpc_client tries to expand641 # This has to be listified because xmlrpc.client tries to expand
642 # sequences of length 1.642 # sequences of length 1.
643 return [{'user_id': 42}]643 return [{'user_id': 42}]
644644
@@ -762,7 +762,7 @@ class TestBugzillaXMLRPCTransport(RequestsTransport):
762762
763 # If the bug doesn't exist, raise a fault.763 # If the bug doesn't exist, raise a fault.
764 if int(bug_id) not in self.bugs:764 if int(bug_id) not in self.bugs:
765 raise xmlrpc_client.Fault(101, "Bug #%s does not exist." % bug_id)765 raise xmlrpc.client.Fault(101, "Bug #%s does not exist." % bug_id)
766766
767 # If we don't have comments for the bug already, create an empty767 # If we don't have comments for the bug already, create an empty
768 # comment dict.768 # comment dict.
@@ -790,7 +790,7 @@ class TestBugzillaXMLRPCTransport(RequestsTransport):
790790
791 self.comment_id_index = comment_id791 self.comment_id_index = comment_id
792792
793 # We have to return a list here because xmlrpc_client will try to793 # We have to return a list here because xmlrpc.client will try to
794 # expand sequences of length 1. Trying to do that on a dict will794 # expand sequences of length 1. Trying to do that on a dict will
795 # cause it to explode.795 # cause it to explode.
796 return [{'comment_id': comment_id}]796 return [{'comment_id': comment_id}]
@@ -810,7 +810,7 @@ class TestBugzillaXMLRPCTransport(RequestsTransport):
810 old_launchpad_id = bug['internals'].get('launchpad_id', 0)810 old_launchpad_id = bug['internals'].get('launchpad_id', 0)
811 bug['internals']['launchpad_id'] = launchpad_id811 bug['internals']['launchpad_id'] = launchpad_id
812812
813 # We need to return a list here because xmlrpc_client will try to813 # We need to return a list here because xmlrpc.client will try to
814 # expand sequences of length 1, which will fail horribly when814 # expand sequences of length 1, which will fail horribly when
815 # the sequence is in fact a dict.815 # the sequence is in fact a dict.
816 return [{'launchpad_id': old_launchpad_id}]816 return [{'launchpad_id': old_launchpad_id}]
@@ -908,7 +908,7 @@ class TestBugzillaAPIXMLRPCTransport(TestBugzillaXMLRPCTransport):
908908
909 def version(self):909 def version(self):
910 """Return the version of Bugzilla being used."""910 """Return the version of Bugzilla being used."""
911 # This is to work around the old "xmlrpc_client tries to expand911 # This is to work around the old "xmlrpc.client tries to expand
912 # sequences of length 1" problem (see above).912 # sequences of length 1" problem (see above).
913 return [{'version': '3.4.1+'}]913 return [{'version': '3.4.1+'}]
914914
@@ -924,7 +924,7 @@ class TestBugzillaAPIXMLRPCTransport(TestBugzillaXMLRPCTransport):
924 self._setAuthCookie()924 self._setAuthCookie()
925 return [{'id': self.users.index(user)}]925 return [{'id': self.users.index(user)}]
926 else:926 else:
927 raise xmlrpc_client.Fault(927 raise xmlrpc.client.Fault(
928 300,928 300,
929 "The username or password you entered is not valid.")929 "The username or password you entered is not valid.")
930930
@@ -1043,7 +1043,7 @@ class TestBugzillaAPIXMLRPCTransport(TestBugzillaXMLRPCTransport):
10431043
1044 # If the bug doesn't exist, raise a fault.1044 # If the bug doesn't exist, raise a fault.
1045 if int(bug_id) not in self.bugs:1045 if int(bug_id) not in self.bugs:
1046 raise xmlrpc_client.Fault(101, "Bug #%s does not exist." % bug_id)1046 raise xmlrpc.client.Fault(101, "Bug #%s does not exist." % bug_id)
10471047
1048 # If we don't have comments for the bug already, create an empty1048 # If we don't have comments for the bug already, create an empty
1049 # comment dict.1049 # comment dict.
@@ -1072,7 +1072,7 @@ class TestBugzillaAPIXMLRPCTransport(TestBugzillaXMLRPCTransport):
10721072
1073 self.comment_id_index = comment_id1073 self.comment_id_index = comment_id
10741074
1075 # We have to return a list here because xmlrpc_client will try to1075 # We have to return a list here because xmlrpc.client will try to
1076 # expand sequences of length 1. Trying to do that on a dict will1076 # expand sequences of length 1. Trying to do that on a dict will
1077 # cause it to explode.1077 # cause it to explode.
1078 return [{'id': comment_id}]1078 return [{'id': comment_id}]
@@ -1091,7 +1091,7 @@ class TestBugzillaAPIXMLRPCTransport(TestBugzillaXMLRPCTransport):
10911091
1092 # If the bug ID doesn't exist, raise a Fault.1092 # If the bug ID doesn't exist, raise a Fault.
1093 if bug_id not in self.bugs:1093 if bug_id not in self.bugs:
1094 raise xmlrpc_client.Fault(1094 raise xmlrpc.client.Fault(
1095 101, "Bug #%s does not exist." % bug_id)1095 101, "Bug #%s does not exist." % bug_id)
10961096
1097 see_also_list = self.bugs[bug_id].get('see_also', [])1097 see_also_list = self.bugs[bug_id].get('see_also', [])
@@ -1122,7 +1122,7 @@ class TestBugzillaAPIXMLRPCTransport(TestBugzillaXMLRPCTransport):
11221122
1123 if ('launchpad' not in url and1123 if ('launchpad' not in url and
1124 'show_bug.cgi' not in url):1124 'show_bug.cgi' not in url):
1125 raise xmlrpc_client.Fault(1125 raise xmlrpc.client.Fault(
1126 112, "Bug URL %s is invalid." % url)1126 112, "Bug URL %s is invalid." % url)
11271127
1128 if changes.get(bug_id) is None:1128 if changes.get(bug_id) is None:
@@ -1140,7 +1140,7 @@ class TestBugzillaAPIXMLRPCTransport(TestBugzillaXMLRPCTransport):
1140 # Replace the bug's existing see_also list.1140 # Replace the bug's existing see_also list.
1141 self.bugs[bug_id]['see_also'] = see_also_list1141 self.bugs[bug_id]['see_also'] = see_also_list
11421142
1143 # We have to return a list here because xmlrpc_client will try to1143 # We have to return a list here because xmlrpc.client will try to
1144 # expand sequences of length 1. Trying to do that on a dict will1144 # expand sequences of length 1. Trying to do that on a dict will
1145 # cause it to explode.1145 # cause it to explode.
1146 return [{'changes': changes}]1146 return [{'changes': changes}]
@@ -1267,7 +1267,7 @@ class TestInternalXMLRPCTransport:
1267 self.quiet = quiet1267 self.quiet = quiet
12681268
1269 def request(self, host, handler, request, verbose=None):1269 def request(self, host, handler, request, verbose=None):
1270 args, method_name = xmlrpc_client.loads(request)1270 args, method_name = xmlrpc.client.loads(request)
1271 method = getattr(self, method_name)1271 method = getattr(self, method_name)
1272 with lp_dbuser():1272 with lp_dbuser():
1273 return method(*args)1273 return method(*args)
@@ -1327,14 +1327,14 @@ class TestTracXMLRPCTransport(RequestsTransport):
1327 """1327 """
1328 assert handler.endswith('/xmlrpc'), (1328 assert handler.endswith('/xmlrpc'), (
1329 'The Trac endpoint must end with /xmlrpc')1329 'The Trac endpoint must end with /xmlrpc')
1330 args, method_name = xmlrpc_client.loads(request)1330 args, method_name = xmlrpc.client.loads(request)
1331 prefix = 'launchpad.'1331 prefix = 'launchpad.'
1332 assert method_name.startswith(prefix), (1332 assert method_name.startswith(prefix), (
1333 'All methods should be in the launchpad namespace')1333 'All methods should be in the launchpad namespace')
1334 if (self.auth_cookie is None or1334 if (self.auth_cookie is None or
1335 self.auth_cookie == self.expired_cookie):1335 self.auth_cookie == self.expired_cookie):
1336 # All the Trac XML-RPC methods need authentication.1336 # All the Trac XML-RPC methods need authentication.
1337 raise xmlrpc_client.ProtocolError(1337 raise xmlrpc.client.ProtocolError(
1338 method_name, errcode=403, errmsg="Forbidden",1338 method_name, errcode=403, errmsg="Forbidden",
1339 headers=None)1339 headers=None)
13401340
@@ -1522,7 +1522,7 @@ class TestTracXMLRPCTransport(RequestsTransport):
1522 return 0. Otherwise return the mapped Launchpad bug ID.1522 return 0. Otherwise return the mapped Launchpad bug ID.
1523 """1523 """
1524 if bugid not in self.remote_bugs:1524 if bugid not in self.remote_bugs:
1525 raise xmlrpc_client.Fault(1525 raise xmlrpc.client.Fault(
1526 FAULT_TICKET_NOT_FOUND, 'Ticket does not exist')1526 FAULT_TICKET_NOT_FOUND, 'Ticket does not exist')
15271527
1528 return [self.utc_time, self.launchpad_bugs.get(bugid, 0)]1528 return [self.utc_time, self.launchpad_bugs.get(bugid, 0)]
@@ -1536,12 +1536,12 @@ class TestTracXMLRPCTransport(RequestsTransport):
1536 Return the current UTC timestamp.1536 Return the current UTC timestamp.
1537 """1537 """
1538 if bugid not in self.remote_bugs:1538 if bugid not in self.remote_bugs:
1539 raise xmlrpc_client.Fault(1539 raise xmlrpc.client.Fault(
1540 FAULT_TICKET_NOT_FOUND, 'Ticket does not exist')1540 FAULT_TICKET_NOT_FOUND, 'Ticket does not exist')
15411541
1542 self.launchpad_bugs[bugid] = launchpad_bug1542 self.launchpad_bugs[bugid] = launchpad_bug
15431543
1544 # Return a list, since xmlrpc_client insists on trying to expand1544 # Return a list, since xmlrpc.client insists on trying to expand
1545 # results.1545 # results.
1546 return [self.utc_time]1546 return [self.utc_time]
15471547
@@ -1698,7 +1698,7 @@ class TestDebBugs(DebBugs):
1698def ensure_response_parser_is_expat(transport):1698def ensure_response_parser_is_expat(transport):
1699 """Ensure the transport always selects the Expat-based response parser.1699 """Ensure the transport always selects the Expat-based response parser.
17001700
1701 The response parser is chosen by xmlrpc_client at runtime from a number1701 The response parser is chosen by xmlrpc.client at runtime from a number
1702 of choices, but the main Launchpad production environment selects Expat1702 of choices, but the main Launchpad production environment selects Expat
1703 at present.1703 at present.
17041704
@@ -1707,8 +1707,8 @@ def ensure_response_parser_is_expat(transport):
1707 response parsers to be chosen.1707 response parsers to be chosen.
1708 """1708 """
1709 def getparser():1709 def getparser():
1710 target = xmlrpc_client.Unmarshaller(1710 target = xmlrpc.client.Unmarshaller(
1711 use_datetime=transport._use_datetime)1711 use_datetime=transport._use_datetime)
1712 parser = xmlrpc_client.ExpatParser(target)1712 parser = xmlrpc.client.ExpatParser(target)
1713 return parser, target1713 return parser, target
1714 transport.getparser = getparser1714 transport.getparser = getparser
diff --git a/lib/lp/bugs/tests/trac-xmlrpc-transport.txt b/lib/lp/bugs/tests/trac-xmlrpc-transport.txt
index 8703cb3..2da5fbb 100644
--- a/lib/lp/bugs/tests/trac-xmlrpc-transport.txt
+++ b/lib/lp/bugs/tests/trac-xmlrpc-transport.txt
@@ -6,11 +6,11 @@ Trac plugin. It can be used to avoid network traffic while testing, and
6it implements the same API that Trac instances having the LP plugin6it implements the same API that Trac instances having the LP plugin
7installed implement.7installed implement.
88
9 >>> from six.moves import xmlrpc_client9 >>> import xmlrpc.client
10 >>> from lp.bugs.tests.externalbugtracker import (10 >>> from lp.bugs.tests.externalbugtracker import (
11 ... TestTracXMLRPCTransport)11 ... TestTracXMLRPCTransport)
12 >>> trac_transport = TestTracXMLRPCTransport('http://example.com/xmlrpc')12 >>> trac_transport = TestTracXMLRPCTransport('http://example.com/xmlrpc')
13 >>> server = xmlrpc_client.ServerProxy(13 >>> server = xmlrpc.client.ServerProxy(
14 ... 'http://example.com/xmlrpc', transport=trac_transport)14 ... 'http://example.com/xmlrpc', transport=trac_transport)
1515
16All the methods need an authentication cookie to be sent.16All the methods need an authentication cookie to be sent.
diff --git a/lib/lp/buildmaster/interactor.py b/lib/lp/buildmaster/interactor.py
index 59f7612..796ea92 100644
--- a/lib/lp/buildmaster/interactor.py
+++ b/lib/lp/buildmaster/interactor.py
@@ -551,7 +551,7 @@ class BuilderInteractor(object):
551 if builder_status == "BuilderStatus.ABORTING":551 if builder_status == "BuilderStatus.ABORTING":
552 logtail = u"Waiting for slave process to be terminated"552 logtail = u"Waiting for slave process to be terminated"
553 elif slave_status.get("logtail") is not None:553 elif slave_status.get("logtail") is not None:
554 # slave_status["logtail"] is an xmlrpc_client.Binary instance,554 # slave_status["logtail"] is an xmlrpc.client.Binary instance,
555 # and the contents might include invalid UTF-8 due to being a555 # and the contents might include invalid UTF-8 due to being a
556 # fixed number of bytes from the tail of the log. Turn it into556 # fixed number of bytes from the tail of the log. Turn it into
557 # Unicode as best we can.557 # Unicode as best we can.
diff --git a/lib/lp/buildmaster/tests/mock_slaves.py b/lib/lp/buildmaster/tests/mock_slaves.py
index df9d0fb..78fa6dc 100644
--- a/lib/lp/buildmaster/tests/mock_slaves.py
+++ b/lib/lp/buildmaster/tests/mock_slaves.py
@@ -20,11 +20,11 @@ __all__ = [
20from collections import OrderedDict20from collections import OrderedDict
21import os21import os
22import sys22import sys
23import xmlrpc.client
2324
24import fixtures25import fixtures
25from lpbuildd.tests.harness import BuilddSlaveTestSetup26from lpbuildd.tests.harness import BuilddSlaveTestSetup
26import six27import six
27from six.moves import xmlrpc_client
28from testtools.content import attach_file28from testtools.content import attach_file
29from twisted.internet import defer29from twisted.internet import defer
30from twisted.web import xmlrpc30from twisted.web import xmlrpc
@@ -160,7 +160,7 @@ class BuildingSlave(OkSlave):
160160
161 def status(self):161 def status(self):
162 self.call_log.append('status')162 self.call_log.append('status')
163 buildlog = xmlrpc_client.Binary(163 buildlog = xmlrpc.client.Binary(
164 b"This is a build log: %d" % self.status_count)164 b"This is a build log: %d" % self.status_count)
165 self.status_count += 1165 self.status_count += 1
166 return defer.succeed({166 return defer.succeed({
@@ -238,7 +238,7 @@ class AbortingSlave(OkSlave):
238class LostBuildingBrokenSlave:238class LostBuildingBrokenSlave:
239 """A mock slave building bogus Build/BuildQueue IDs that can't be aborted.239 """A mock slave building bogus Build/BuildQueue IDs that can't be aborted.
240240
241 When 'aborted' it raises an xmlrpc_client.Fault(8002, 'Could not abort')241 When 'aborted' it raises an xmlrpc.client.Fault(8002, 'Could not abort')
242 """242 """
243243
244 def __init__(self):244 def __init__(self):
@@ -253,7 +253,7 @@ class LostBuildingBrokenSlave:
253253
254 def abort(self):254 def abort(self):
255 self.call_log.append('abort')255 self.call_log.append('abort')
256 return defer.fail(xmlrpc_client.Fault(8002, "Could not abort"))256 return defer.fail(xmlrpc.client.Fault(8002, "Could not abort"))
257257
258 def resume(self):258 def resume(self):
259 self.call_log.append('resume')259 self.call_log.append('resume')
@@ -268,7 +268,7 @@ class BrokenSlave:
268268
269 def status(self):269 def status(self):
270 self.call_log.append('status')270 self.call_log.append('status')
271 return defer.fail(xmlrpc_client.Fault(8001, "Broken slave"))271 return defer.fail(xmlrpc.client.Fault(8001, "Broken slave"))
272272
273273
274class TrivialBehaviour:274class TrivialBehaviour:
diff --git a/lib/lp/buildmaster/tests/test_interactor.py b/lib/lp/buildmaster/tests/test_interactor.py
index 19572f2..013ab32 100644
--- a/lib/lp/buildmaster/tests/test_interactor.py
+++ b/lib/lp/buildmaster/tests/test_interactor.py
@@ -12,10 +12,10 @@ import hashlib
12import os12import os
13import signal13import signal
14import tempfile14import tempfile
15import xmlrpc.client
1516
16from lpbuildd.builder import BuilderStatus17from lpbuildd.builder import BuilderStatus
17import six18import six
18from six.moves import xmlrpc_client
19from testtools.matchers import ContainsAll19from testtools.matchers import ContainsAll
20from testtools.testcase import ExpectedException20from testtools.testcase import ExpectedException
21from testtools.twistedsupport import (21from testtools.twistedsupport import (
@@ -291,7 +291,7 @@ class TestBuilderInteractorCleanSlave(TestCase):
291 try:291 try:
292 yield BuilderInteractor.cleanSlave(292 yield BuilderInteractor.cleanSlave(
293 vitals, slave, MockBuilderFactory(builder, None))293 vitals, slave, MockBuilderFactory(builder, None))
294 except xmlrpc_client.Fault:294 except xmlrpc.client.Fault:
295 self.assertEqual(['status', 'abort'], slave.call_log)295 self.assertEqual(['status', 'abort'], slave.call_log)
296 else:296 else:
297 self.fail("abort() should crash.")297 self.fail("abort() should crash.")
@@ -325,7 +325,7 @@ class TestBuilderSlaveStatus(TestCase):
325 del status["build_id"]325 del status["build_id"]
326 if logtail:326 if logtail:
327 tail = status.pop("logtail")327 tail = status.pop("logtail")
328 self.assertIsInstance(tail, xmlrpc_client.Binary)328 self.assertIsInstance(tail, xmlrpc.client.Binary)
329329
330 self.assertEqual(expected, status)330 self.assertEqual(expected, status)
331331
@@ -584,7 +584,7 @@ class TestSlave(TestCase):
584 status = yield slave.status()584 status = yield slave.status()
585 self.assertEqual(BuilderStatus.BUILDING, status['builder_status'])585 self.assertEqual(BuilderStatus.BUILDING, status['builder_status'])
586 self.assertEqual(build_id, status['build_id'])586 self.assertEqual(build_id, status['build_id'])
587 self.assertIsInstance(status['logtail'], xmlrpc_client.Binary)587 self.assertIsInstance(status['logtail'], xmlrpc.client.Binary)
588588
589 @defer.inlineCallbacks589 @defer.inlineCallbacks
590 def test_ensurepresent_not_there(self):590 def test_ensurepresent_not_there(self):
diff --git a/lib/lp/buildmaster/tests/test_manager.py b/lib/lp/buildmaster/tests/test_manager.py
index 0187dc2..fd84f13 100644
--- a/lib/lp/buildmaster/tests/test_manager.py
+++ b/lib/lp/buildmaster/tests/test_manager.py
@@ -11,9 +11,9 @@ import os
11import signal11import signal
12import time12import time
13from unittest import mock13from unittest import mock
14import xmlrpc.client
1415
15import six16import six
16from six.moves import xmlrpc_client
17from testtools.matchers import Equals17from testtools.matchers import Equals
18from testtools.testcase import ExpectedException18from testtools.testcase import ExpectedException
19from testtools.twistedsupport import AsynchronousDeferredRunTest19from testtools.twistedsupport import AsynchronousDeferredRunTest
@@ -308,7 +308,7 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
308 builder.failure_count = 0308 builder.failure_count = 0
309 transaction.commit()309 transaction.commit()
310 scanner = self._getScanner(builder_name=builder.name)310 scanner = self._getScanner(builder_name=builder.name)
311 with ExpectedException(xmlrpc_client.Fault):311 with ExpectedException(xmlrpc.client.Fault):
312 yield scanner.scan()312 yield scanner.scan()
313313
314 @defer.inlineCallbacks314 @defer.inlineCallbacks
@@ -319,7 +319,7 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
319 @defer.inlineCallbacks319 @defer.inlineCallbacks
320 def status(self):320 def status(self):
321 status = yield super(BrokenUTF8Slave, self).status()321 status = yield super(BrokenUTF8Slave, self).status()
322 status["logtail"] = xmlrpc_client.Binary(322 status["logtail"] = xmlrpc.client.Binary(
323 u"───".encode("UTF-8")[1:])323 u"───".encode("UTF-8")[1:])
324 return status324 return status
325325
@@ -349,7 +349,7 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
349 @defer.inlineCallbacks349 @defer.inlineCallbacks
350 def status(self):350 def status(self):
351 status = yield super(NULSlave, self).status()351 status = yield super(NULSlave, self).status()
352 status["logtail"] = xmlrpc_client.Binary(b"foo\0bar\0baz")352 status["logtail"] = xmlrpc.client.Binary(b"foo\0bar\0baz")
353 return status353 return status
354354
355 builder = getUtility(IBuilderSet)[BOB_THE_BUILDER_NAME]355 builder = getUtility(IBuilderSet)[BOB_THE_BUILDER_NAME]
@@ -1196,7 +1196,7 @@ class TestCancellationChecking(TestCaseWithFactory):
1196 slave = LostBuildingBrokenSlave()1196 slave = LostBuildingBrokenSlave()
1197 self.builder.current_build.cancel()1197 self.builder.current_build.cancel()
1198 with ExpectedException(1198 with ExpectedException(
1199 xmlrpc_client.Fault, "<Fault 8002: %r>" % 'Could not abort'):1199 xmlrpc.client.Fault, "<Fault 8002: %r>" % 'Could not abort'):
1200 yield self._getScanner().checkCancellation(self.vitals, slave)1200 yield self._getScanner().checkCancellation(self.vitals, slave)
12011201
12021202
diff --git a/lib/lp/code/doc/branch-xmlrpc.txt b/lib/lp/code/doc/branch-xmlrpc.txt
index ba2981b..80e782b 100644
--- a/lib/lp/code/doc/branch-xmlrpc.txt
+++ b/lib/lp/code/doc/branch-xmlrpc.txt
@@ -1,7 +1,7 @@
1IPublicCodehostingAPI1IPublicCodehostingAPI
2=====================2=====================
33
4 >>> from six.moves import xmlrpc_client4 >>> import xmlrpc.client
5 >>> from lp.testing.xmlrpc import XMLRPCTestTransport5 >>> from lp.testing.xmlrpc import XMLRPCTestTransport
66
77
@@ -17,7 +17,7 @@ Bazaar is strictly unsupported.
17This API is deprecated, and will eventually be replaced with an17This API is deprecated, and will eventually be replaced with an
18equivalent method in the new Launchpad API infrastructure.18equivalent method in the new Launchpad API infrastructure.
1919
20 >>> public_codehosting_api = xmlrpc_client.ServerProxy(20 >>> public_codehosting_api = xmlrpc.client.ServerProxy(
21 ... 'http://xmlrpc.launchpad.test/bazaar/',21 ... 'http://xmlrpc.launchpad.test/bazaar/',
22 ... transport=XMLRPCTestTransport())22 ... transport=XMLRPCTestTransport())
2323
diff --git a/lib/lp/code/doc/xmlrpc-codeimport-scheduler.txt b/lib/lp/code/doc/xmlrpc-codeimport-scheduler.txt
index e60b0d7..ba4b363 100644
--- a/lib/lp/code/doc/xmlrpc-codeimport-scheduler.txt
+++ b/lib/lp/code/doc/xmlrpc-codeimport-scheduler.txt
@@ -42,9 +42,9 @@ can be found in the tests for ICodeImportJobSet.
4242
43The point of all this is for it to be accessed over XMLRPC.43The point of all this is for it to be accessed over XMLRPC.
4444
45 >>> from six.moves import xmlrpc_client45 >>> import xmlrpc.client
46 >>> from lp.testing.xmlrpc import XMLRPCTestTransport46 >>> from lp.testing.xmlrpc import XMLRPCTestTransport
47 >>> codeimportscheduler = xmlrpc_client.ServerProxy(47 >>> codeimportscheduler = xmlrpc.client.ServerProxy(
48 ... 'http://xmlrpc-private.launchpad.test:8087/codeimportscheduler',48 ... 'http://xmlrpc-private.launchpad.test:8087/codeimportscheduler',
49 ... transport=XMLRPCTestTransport())49 ... transport=XMLRPCTestTransport())
50 >>> codeimportscheduler.getJobForMachine('bazaar-importer', 2)50 >>> codeimportscheduler.getJobForMachine('bazaar-importer', 2)
diff --git a/lib/lp/code/interfaces/codeimportscheduler.py b/lib/lp/code/interfaces/codeimportscheduler.py
index 47d2b3c..ea1a095 100644
--- a/lib/lp/code/interfaces/codeimportscheduler.py
+++ b/lib/lp/code/interfaces/codeimportscheduler.py
@@ -59,8 +59,8 @@ class ICodeImportScheduler(Interface):
59 :param job_id: The ID of the code import job to finish.59 :param job_id: The ID of the code import job to finish.
60 :param status_name: The outcome of the job as the name of a60 :param status_name: The outcome of the job as the name of a
61 `CodeImportResultStatus` item.61 `CodeImportResultStatus` item.
62 :param log_file: A log file to display for diagnostics, either as a62 :param log_file: A log file to display for diagnostics, either as an
63 `six.moves.xmlrpc_client.Binary` containing the log file data or63 `xmlrpc.client.Binary` containing the log file data or
64 as the URL of a file in the librarian.64 as the URL of a file in the librarian.
65 :raise NoSuchCodeImportJob: if no job with id `job_id` exists.65 :raise NoSuchCodeImportJob: if no job with id `job_id` exists.
66 """66 """
diff --git a/lib/lp/code/xmlrpc/branch.py b/lib/lp/code/xmlrpc/branch.py
index 235e23e..4833639 100644
--- a/lib/lp/code/xmlrpc/branch.py
+++ b/lib/lp/code/xmlrpc/branch.py
@@ -8,9 +8,9 @@ __all__ = [
8 'PublicCodehostingAPI',8 'PublicCodehostingAPI',
9 ]9 ]
1010
11from xmlrpc.client import Fault
1112
12from breezy import urlutils13from breezy import urlutils
13from six.moves.xmlrpc_client import Fault
14from zope.component import getUtility14from zope.component import getUtility
15from zope.interface import (15from zope.interface import (
16 implementer,16 implementer,
diff --git a/lib/lp/code/xmlrpc/codeimportscheduler.py b/lib/lp/code/xmlrpc/codeimportscheduler.py
index 0641af4..966b271 100644
--- a/lib/lp/code/xmlrpc/codeimportscheduler.py
+++ b/lib/lp/code/xmlrpc/codeimportscheduler.py
@@ -8,9 +8,9 @@ __all__ = [
8 ]8 ]
99
10import io10import io
11import xmlrpc.client
1112
12import six13import six
13from six.moves import xmlrpc_client
14from zope.component import getUtility14from zope.component import getUtility
15from zope.interface import implementer15from zope.interface import implementer
16from zope.security.proxy import removeSecurityProxy16from zope.security.proxy import removeSecurityProxy
@@ -92,7 +92,7 @@ class CodeImportSchedulerAPI(LaunchpadXMLRPCView):
92 job = self._getJob(job_id)92 job = self._getJob(job_id)
93 status = CodeImportResultStatus.items[status_name]93 status = CodeImportResultStatus.items[status_name]
94 workflow = removeSecurityProxy(getUtility(ICodeImportJobWorkflow))94 workflow = removeSecurityProxy(getUtility(ICodeImportJobWorkflow))
95 if isinstance(log_file, xmlrpc_client.Binary):95 if isinstance(log_file, xmlrpc.client.Binary):
96 if log_file.data:96 if log_file.data:
97 log_file_name = '%s.log' % (97 log_file_name = '%s.log' % (
98 job.code_import.target.unique_name[1:].replace('/', '-'))98 job.code_import.target.unique_name[1:].replace('/', '-'))
diff --git a/lib/lp/code/xmlrpc/git.py b/lib/lp/code/xmlrpc/git.py
index b73df08..c7940f0 100644
--- a/lib/lp/code/xmlrpc/git.py
+++ b/lib/lp/code/xmlrpc/git.py
@@ -10,10 +10,10 @@ __all__ = [
10import logging10import logging
11import sys11import sys
12import uuid12import uuid
13import xmlrpc.client
1314
14from pymacaroons import Macaroon15from pymacaroons import Macaroon
15import six16import six
16from six.moves import xmlrpc_client
17from six.moves.urllib.parse import quote17from six.moves.urllib.parse import quote
18import transaction18import transaction
19from zope.component import (19from zope.component import (
@@ -454,7 +454,7 @@ class GitAPI(LaunchpadXMLRPCView):
454 requester_id, self._translatePath,454 requester_id, self._translatePath,
455 six.ensure_text(path).strip("/"), permission, auth_params)455 six.ensure_text(path).strip("/"), permission, auth_params)
456 try:456 try:
457 if isinstance(result, xmlrpc_client.Fault):457 if isinstance(result, xmlrpc.client.Fault):
458 logger.error("translatePath failed: %r", result)458 logger.error("translatePath failed: %r", result)
459 else:459 else:
460 # The results of path translation are not sensitive for460 # The results of path translation are not sensitive for
@@ -502,7 +502,7 @@ class GitAPI(LaunchpadXMLRPCView):
502 requester_id, self._notify,502 requester_id, self._notify,
503 translated_path, statistics, auth_params)503 translated_path, statistics, auth_params)
504 try:504 try:
505 if isinstance(result, xmlrpc_client.Fault):505 if isinstance(result, xmlrpc.client.Fault):
506 logger.error("notify failed: %r", result)506 logger.error("notify failed: %r", result)
507 else:507 else:
508 logger.info("notify succeeded: %s" % result)508 logger.info("notify succeeded: %s" % result)
@@ -544,7 +544,7 @@ class GitAPI(LaunchpadXMLRPCView):
544 requester_id, self._getMergeProposalURL,544 requester_id, self._getMergeProposalURL,
545 translated_path, branch, auth_params)545 translated_path, branch, auth_params)
546 try:546 try:
547 if isinstance(result, xmlrpc_client.Fault):547 if isinstance(result, xmlrpc.client.Fault):
548 logger.error("getMergeProposalURL failed: %r", result)548 logger.error("getMergeProposalURL failed: %r", result)
549 else:549 else:
550 # The result of getMergeProposalURL is not sensitive for550 # The result of getMergeProposalURL is not sensitive for
@@ -586,7 +586,7 @@ class GitAPI(LaunchpadXMLRPCView):
586 "Request received: authenticateWithPassword('%s')", username)586 "Request received: authenticateWithPassword('%s')", username)
587 result = self._authenticateWithPassword(username, password)587 result = self._authenticateWithPassword(username, password)
588 try:588 try:
589 if isinstance(result, xmlrpc_client.Fault):589 if isinstance(result, xmlrpc.client.Fault):
590 logger.error("authenticateWithPassword failed: %r", result)590 logger.error("authenticateWithPassword failed: %r", result)
591 else:591 else:
592 # The results of authentication may be sensitive, but we can592 # The results of authentication may be sensitive, but we can
@@ -640,7 +640,7 @@ class GitAPI(LaunchpadXMLRPCView):
640 # the moment. It's possible to reach this by being very unlucky640 # the moment. It's possible to reach this by being very unlucky
641 # about the timing of a push.641 # about the timing of a push.
642 return [642 return [
643 (xmlrpc_client.Binary(ref_path.data), [])643 (xmlrpc.client.Binary(ref_path.data), [])
644 for ref_path in ref_paths]644 for ref_path in ref_paths]
645645
646 # Caller sends paths as bytes; Launchpad returns a list of (path,646 # Caller sends paths as bytes; Launchpad returns a list of (path,
@@ -648,7 +648,7 @@ class GitAPI(LaunchpadXMLRPCView):
648 # bytes.)648 # bytes.)
649 ref_paths = [ref_path.data for ref_path in ref_paths]649 ref_paths = [ref_path.data for ref_path in ref_paths]
650 return [650 return [
651 (xmlrpc_client.Binary(ref_path),651 (xmlrpc.client.Binary(ref_path),
652 self._renderPermissions(permissions))652 self._renderPermissions(permissions))
653 for ref_path, permissions in repository.checkRefPermissions(653 for ref_path, permissions in repository.checkRefPermissions(
654 requester, ref_paths).items()654 requester, ref_paths).items()
@@ -666,7 +666,7 @@ class GitAPI(LaunchpadXMLRPCView):
666 requester_id, self._checkRefPermissions,666 requester_id, self._checkRefPermissions,
667 translated_path, ref_paths, auth_params)667 translated_path, ref_paths, auth_params)
668 try:668 try:
669 if isinstance(result, xmlrpc_client.Fault):669 if isinstance(result, xmlrpc.client.Fault):
670 logger.error("checkRefPermissions failed: %r", result)670 logger.error("checkRefPermissions failed: %r", result)
671 else:671 else:
672 # The results of ref permission checks are not sensitive for672 # The results of ref permission checks are not sensitive for
@@ -736,7 +736,7 @@ class GitAPI(LaunchpadXMLRPCView):
736 except Exception as e:736 except Exception as e:
737 result = e737 result = e
738 try:738 try:
739 if isinstance(result, xmlrpc_client.Fault):739 if isinstance(result, xmlrpc.client.Fault):
740 logger.error("confirmRepoCreation failed: %r", result)740 logger.error("confirmRepoCreation failed: %r", result)
741 else:741 else:
742 logger.info("confirmRepoCreation succeeded: %s" % result)742 logger.info("confirmRepoCreation succeeded: %s" % result)
@@ -767,7 +767,7 @@ class GitAPI(LaunchpadXMLRPCView):
767 except Exception as e:767 except Exception as e:
768 result = e768 result = e
769 try:769 try:
770 if isinstance(result, xmlrpc_client.Fault):770 if isinstance(result, xmlrpc.client.Fault):
771 logger.error("abortRepoCreation failed: %r", result)771 logger.error("abortRepoCreation failed: %r", result)
772 else:772 else:
773 logger.info("abortRepoCreation succeeded: %s" % result)773 logger.info("abortRepoCreation succeeded: %s" % result)
diff --git a/lib/lp/code/xmlrpc/tests/test_branch.py b/lib/lp/code/xmlrpc/tests/test_branch.py
index 898ebd6..41d55d7 100644
--- a/lib/lp/code/xmlrpc/tests/test_branch.py
+++ b/lib/lp/code/xmlrpc/tests/test_branch.py
@@ -4,10 +4,10 @@
4"""Unit tests for the public codehosting API."""4"""Unit tests for the public codehosting API."""
55
6import os6import os
7import xmlrpc.client
78
8from breezy import urlutils9from breezy import urlutils
9from lazr.uri import URI10from lazr.uri import URI
10from six.moves import xmlrpc_client
11from zope.security.proxy import removeSecurityProxy11from zope.security.proxy import removeSecurityProxy
1212
13from lp.app.enums import InformationType13from lp.app.enums import InformationType
@@ -79,7 +79,7 @@ class TestExpandURL(TestCaseWithFactory):
79 api = PublicCodehostingAPI(None, None)79 api = PublicCodehostingAPI(None, None)
80 fault = api.resolve_lp_path(lp_url_path)80 fault = api.resolve_lp_path(lp_url_path)
81 self.assertTrue(81 self.assertTrue(
82 isinstance(fault, xmlrpc_client.Fault),82 isinstance(fault, xmlrpc.client.Fault),
83 "resolve_lp_path(%r) returned %r, not a Fault."83 "resolve_lp_path(%r) returned %r, not a Fault."
84 % (lp_url_path, fault))84 % (lp_url_path, fault))
85 self.assertEqual(expected_fault.__class__, fault.__class__)85 self.assertEqual(expected_fault.__class__, fault.__class__)
diff --git a/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py b/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py
index 8a77f5b..7c0ec97 100644
--- a/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py
+++ b/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py
@@ -3,7 +3,8 @@
33
4"""Test for the methods of `ICodeImportScheduler`."""4"""Test for the methods of `ICodeImportScheduler`."""
55
6from six.moves import xmlrpc_client6import xmlrpc.client
7
7import transaction8import transaction
8from zope.component import getUtility9from zope.component import getUtility
9from zope.security.proxy import removeSecurityProxy10from zope.security.proxy import removeSecurityProxy
@@ -76,7 +77,7 @@ class TestCodeImportSchedulerAPI(TestCaseWithFactory):
76 # is no code import job with the given ID.77 # is no code import job with the given ID.
77 fault = self.api.getImportDataForJobID(-1)78 fault = self.api.getImportDataForJobID(-1)
78 self.assertTrue(79 self.assertTrue(
79 isinstance(fault, xmlrpc_client.Fault),80 isinstance(fault, xmlrpc.client.Fault),
80 "getImportDataForJobID(-1) returned %r, not a Fault."81 "getImportDataForJobID(-1) returned %r, not a Fault."
81 % (fault,))82 % (fault,))
82 self.assertEqual(NoSuchCodeImportJob, fault.__class__)83 self.assertEqual(NoSuchCodeImportJob, fault.__class__)
@@ -95,7 +96,7 @@ class TestCodeImportSchedulerAPI(TestCaseWithFactory):
95 # code import job with the given ID.96 # code import job with the given ID.
96 fault = self.api.updateHeartbeat(-1, '')97 fault = self.api.updateHeartbeat(-1, '')
97 self.assertTrue(98 self.assertTrue(
98 isinstance(fault, xmlrpc_client.Fault),99 isinstance(fault, xmlrpc.client.Fault),
99 "updateHeartbeat(-1, '') returned %r, not a Fault."100 "updateHeartbeat(-1, '') returned %r, not a Fault."
100 % (fault,))101 % (fault,))
101 self.assertEqual(NoSuchCodeImportJob, fault.__class__)102 self.assertEqual(NoSuchCodeImportJob, fault.__class__)
@@ -131,7 +132,7 @@ class TestCodeImportSchedulerAPI(TestCaseWithFactory):
131 code_import = code_import_job.code_import132 code_import = code_import_job.code_import
132 self.api.finishJobID(133 self.api.finishJobID(
133 code_import_job.id, CodeImportResultStatus.SUCCESS.name,134 code_import_job.id, CodeImportResultStatus.SUCCESS.name,
134 xmlrpc_client.Binary(b'log file data\n'))135 xmlrpc.client.Binary(b'log file data\n'))
135 transaction.commit()136 transaction.commit()
136 self.assertEqual(137 self.assertEqual(
137 b'log file data\n', code_import.results.last().log_file.read())138 b'log file data\n', code_import.results.last().log_file.read())
@@ -143,7 +144,7 @@ class TestCodeImportSchedulerAPI(TestCaseWithFactory):
143 code_import = code_import_job.code_import144 code_import = code_import_job.code_import
144 self.api.finishJobID(145 self.api.finishJobID(
145 code_import_job.id, CodeImportResultStatus.SUCCESS.name,146 code_import_job.id, CodeImportResultStatus.SUCCESS.name,
146 xmlrpc_client.Binary(b''))147 xmlrpc.client.Binary(b''))
147 self.assertIsNone(code_import.results.last().log_file)148 self.assertIsNone(code_import.results.last().log_file)
148149
149 def test_finishJobID_not_found(self):150 def test_finishJobID_not_found(self):
@@ -152,7 +153,7 @@ class TestCodeImportSchedulerAPI(TestCaseWithFactory):
152 fault = self.api.finishJobID(153 fault = self.api.finishJobID(
153 -1, CodeImportResultStatus.SUCCESS.name, '')154 -1, CodeImportResultStatus.SUCCESS.name, '')
154 self.assertTrue(155 self.assertTrue(
155 isinstance(fault, xmlrpc_client.Fault),156 isinstance(fault, xmlrpc.client.Fault),
156 "finishJobID(-1, 'SUCCESS', 0) returned %r, not a Fault."157 "finishJobID(-1, 'SUCCESS', 0) returned %r, not a Fault."
157 % (fault,))158 % (fault,))
158 self.assertEqual(NoSuchCodeImportJob, fault.__class__)159 self.assertEqual(NoSuchCodeImportJob, fault.__class__)
diff --git a/lib/lp/code/xmlrpc/tests/test_git.py b/lib/lp/code/xmlrpc/tests/test_git.py
index 6726db0..27c78c4 100644
--- a/lib/lp/code/xmlrpc/tests/test_git.py
+++ b/lib/lp/code/xmlrpc/tests/test_git.py
@@ -6,12 +6,12 @@
6from datetime import datetime6from datetime import datetime
7import hashlib7import hashlib
8import uuid8import uuid
9import xmlrpc.client
910
10from fixtures import FakeLogger11from fixtures import FakeLogger
11from pymacaroons import Macaroon12from pymacaroons import Macaroon
12import pytz13import pytz
13import six14import six
14from six.moves import xmlrpc_client
15from six.moves.urllib.parse import quote15from six.moves.urllib.parse import quote
16from storm.store import Store16from storm.store import Store
17from testtools.matchers import (17from testtools.matchers import (
@@ -157,7 +157,7 @@ class TestGitAPIMixin:
157157
158 def setUp(self):158 def setUp(self):
159 super(TestGitAPIMixin, self).setUp()159 super(TestGitAPIMixin, self).setUp()
160 self.git_api = xmlrpc_client.ServerProxy(160 self.git_api = xmlrpc.client.ServerProxy(
161 "http://xmlrpc-private.launchpad.test:8087/git",161 "http://xmlrpc-private.launchpad.test:8087/git",
162 transport=XMLRPCTestTransport())162 transport=XMLRPCTestTransport())
163 self.hosting_fixture = self.useFixture(GitHostingFixture())163 self.hosting_fixture = self.useFixture(GitHostingFixture())
@@ -169,7 +169,7 @@ class TestGitAPIMixin:
169 """Assert that a call raises the expected fault."""169 """Assert that a call raises the expected fault."""
170 with FakeLogger() as logger:170 with FakeLogger() as logger:
171 fault = self.assertRaises(171 fault = self.assertRaises(
172 xmlrpc_client.Fault, getattr(self.git_api, func_name),172 xmlrpc.client.Fault, getattr(self.git_api, func_name),
173 *args, **kwargs)173 *args, **kwargs)
174 self.assertThat(fault, MatchesFault(expected_fault))174 self.assertThat(fault, MatchesFault(expected_fault))
175 self.assertThat(logger.output, MatchesRegex(175 self.assertThat(logger.output, MatchesRegex(
@@ -468,14 +468,14 @@ class TestGitAPIMixin:
468 request_id = auth_params["request-id"]468 request_id = auth_params["request-id"]
469 translated_path = removeSecurityProxy(repository).getInternalPath()469 translated_path = removeSecurityProxy(repository).getInternalPath()
470 ref_paths = [470 ref_paths = [
471 xmlrpc_client.Binary(ref_path) for ref_path in ref_paths]471 xmlrpc.client.Binary(ref_path) for ref_path in ref_paths]
472 results = self.assertDoesNotFault(472 results = self.assertDoesNotFault(
473 request_id, "checkRefPermissions",473 request_id, "checkRefPermissions",
474 translated_path, ref_paths, auth_params)474 translated_path, ref_paths, auth_params)
475 self.assertThat(results, MatchesSetwise(*(475 self.assertThat(results, MatchesSetwise(*(
476 MatchesListwise([476 MatchesListwise([
477 MatchesAll(477 MatchesAll(
478 IsInstance(xmlrpc_client.Binary),478 IsInstance(xmlrpc.client.Binary),
479 MatchesStructure.byEquality(data=ref_path)),479 MatchesStructure.byEquality(data=ref_path)),
480 Equals(ref_permissions),480 Equals(ref_permissions),
481 ])481 ])
diff --git a/lib/lp/codehosting/inmemory.py b/lib/lp/codehosting/inmemory.py
index f23c4e5..d68cc22 100644
--- a/lib/lp/codehosting/inmemory.py
+++ b/lib/lp/codehosting/inmemory.py
@@ -9,13 +9,13 @@ __all__ = [
9 ]9 ]
1010
11import operator11import operator
12from xmlrpc.client import Fault
1213
13from breezy.urlutils import (14from breezy.urlutils import (
14 escape,15 escape,
15 unescape,16 unescape,
16 )17 )
17import six18import six
18from six.moves.xmlrpc_client import Fault
19from twisted.internet import defer19from twisted.internet import defer
20from zope.component import (20from zope.component import (
21 adapter,21 adapter,
diff --git a/lib/lp/codehosting/tests/test_acceptance.py b/lib/lp/codehosting/tests/test_acceptance.py
index 1bf9d70..7189670 100644
--- a/lib/lp/codehosting/tests/test_acceptance.py
+++ b/lib/lp/codehosting/tests/test_acceptance.py
@@ -5,6 +5,7 @@
55
6import os6import os
7import re7import re
8import xmlrpc.client
89
9import breezy.branch10import breezy.branch
10from breezy.tests import TestCaseWithTransport11from breezy.tests import TestCaseWithTransport
@@ -12,7 +13,6 @@ from breezy.tests.per_repository import all_repository_format_scenarios
12from breezy.urlutils import local_path_from_url13from breezy.urlutils import local_path_from_url
13from breezy.workingtree import WorkingTree14from breezy.workingtree import WorkingTree
14import six15import six
15from six.moves import xmlrpc_client
16from six.moves.urllib.request import urlopen16from six.moves.urllib.request import urlopen
17from testscenarios import (17from testscenarios import (
18 load_tests_apply_scenarios,18 load_tests_apply_scenarios,
@@ -229,9 +229,9 @@ class SSHTestCase(TestCaseWithTransport, LoomTestMixin, TestCaseWithFactory):
229 Used to create branches that the test user is not able to create, and229 Used to create branches that the test user is not able to create, and
230 might not even be able to view.230 might not even be able to view.
231 """231 """
232 authserver = xmlrpc_client.ServerProxy(232 authserver = xmlrpc.client.ServerProxy(
233 config.codehosting.authentication_endpoint)233 config.codehosting.authentication_endpoint)
234 codehosting_api = xmlrpc_client.ServerProxy(234 codehosting_api = xmlrpc.client.ServerProxy(
235 config.codehosting.codehosting_endpoint)235 config.codehosting.codehosting_endpoint)
236 if creator is None:236 if creator is None:
237 creator_id = authserver.getUserAndSSHKeys(user)['id']237 creator_id = authserver.getUserAndSSHKeys(user)['id']
diff --git a/lib/lp/codehosting/vfs/branchfs.py b/lib/lp/codehosting/vfs/branchfs.py
index 02cf0e0..240892b 100644
--- a/lib/lp/codehosting/vfs/branchfs.py
+++ b/lib/lp/codehosting/vfs/branchfs.py
@@ -54,6 +54,7 @@ __all__ = [
5454
55import os.path55import os.path
56import sys56import sys
57import xmlrpc.client
5758
58from breezy import urlutils59from breezy import urlutils
59from breezy.bzr.bzrdir import BzrDir60from breezy.bzr.bzrdir import BzrDir
@@ -69,7 +70,6 @@ from breezy.transport import get_transport
69from breezy.transport.memory import MemoryServer70from breezy.transport.memory import MemoryServer
70from lazr.uri import URI71from lazr.uri import URI
71import six72import six
72from six.moves import xmlrpc_client
73from twisted.internet import (73from twisted.internet import (
74 defer,74 defer,
75 error,75 error,
@@ -170,7 +170,7 @@ def is_lock_directory(absolute_path):
170170
171def get_ro_server():171def get_ro_server():
172 """Get a Launchpad internal server for scanning branches."""172 """Get a Launchpad internal server for scanning branches."""
173 proxy = xmlrpc_client.ServerProxy(config.codehosting.codehosting_endpoint)173 proxy = xmlrpc.client.ServerProxy(config.codehosting.codehosting_endpoint)
174 codehosting_endpoint = DeferredBlockingProxy(proxy)174 codehosting_endpoint = DeferredBlockingProxy(proxy)
175 branch_transport = get_readonly_transport(175 branch_transport = get_readonly_transport(
176 get_transport(config.codehosting.internal_branch_by_id_root))176 get_transport(config.codehosting.internal_branch_by_id_root))
@@ -193,7 +193,7 @@ def get_rw_server(direct_database=False):
193 if direct_database:193 if direct_database:
194 return DirectDatabaseLaunchpadServer('lp-internal:///', transport)194 return DirectDatabaseLaunchpadServer('lp-internal:///', transport)
195 else:195 else:
196 proxy = xmlrpc_client.ServerProxy(196 proxy = xmlrpc.client.ServerProxy(
197 config.codehosting.codehosting_endpoint)197 config.codehosting.codehosting_endpoint)
198 codehosting_endpoint = DeferredBlockingProxy(proxy)198 codehosting_endpoint = DeferredBlockingProxy(proxy)
199 return LaunchpadInternalServer(199 return LaunchpadInternalServer(
@@ -749,7 +749,7 @@ def get_lp_server(user_id, codehosting_endpoint_url=None, branch_url=None,
749 raise AssertionError(749 raise AssertionError(
750 "can't supply both branch_url and branch_transport!")750 "can't supply both branch_url and branch_transport!")
751751
752 codehosting_client = xmlrpc_client.ServerProxy(codehosting_endpoint_url)752 codehosting_client = xmlrpc.client.ServerProxy(codehosting_endpoint_url)
753 lp_server = LaunchpadServer(753 lp_server = LaunchpadServer(
754 DeferredBlockingProxy(codehosting_client), user_id, branch_transport,754 DeferredBlockingProxy(codehosting_client), user_id, branch_transport,
755 seen_new_branch_hook)755 seen_new_branch_hook)
diff --git a/lib/lp/codehosting/vfs/tests/test_branchfs.py b/lib/lp/codehosting/vfs/tests/test_branchfs.py
index 057c231..d2b96a3 100644
--- a/lib/lp/codehosting/vfs/tests/test_branchfs.py
+++ b/lib/lp/codehosting/vfs/tests/test_branchfs.py
@@ -6,6 +6,7 @@
6import os6import os
7import re7import re
8import sys8import sys
9import xmlrpc.client
910
10from breezy import errors11from breezy import errors
11from breezy.bzr.bzrdir import BzrDir12from breezy.bzr.bzrdir import BzrDir
@@ -33,7 +34,6 @@ from breezy.urlutils import (
33 )34 )
34from fixtures import MonkeyPatch35from fixtures import MonkeyPatch
35import six36import six
36from six.moves import xmlrpc_client
37from testtools.twistedsupport import (37from testtools.twistedsupport import (
38 assert_fails_with,38 assert_fails_with,
39 AsynchronousDeferredRunTest,39 AsynchronousDeferredRunTest,
@@ -1035,7 +1035,7 @@ class TestBranchChangedErrorHandling(TestCaseWithTransport, TestCase):
1035 report = errorlog.globalErrorUtility.raising(f, request)1035 report = errorlog.globalErrorUtility.raising(f, request)
1036 # Record the id for checking later.1036 # Record the id for checking later.
1037 self.generated_oopsids.append(report['id'])1037 self.generated_oopsids.append(report['id'])
1038 raise xmlrpc_client.Fault(-1, report)1038 raise xmlrpc.client.Fault(-1, report)
10391039
1040 def get_server(self):1040 def get_server(self):
1041 if self._server is None:1041 if self._server is None:
diff --git a/lib/lp/registry/tests/mailinglists_helper.py b/lib/lp/registry/tests/mailinglists_helper.py
index 2f926d9..20ace5c 100644
--- a/lib/lp/registry/tests/mailinglists_helper.py
+++ b/lib/lp/registry/tests/mailinglists_helper.py
@@ -10,7 +10,8 @@ __all__ = [
10 'new_team',10 'new_team',
11 ]11 ]
1212
13from six.moves import xmlrpc_client13import xmlrpc.client
14
14from zope.component import getUtility15from zope.component import getUtility
1516
16from lp.registry.enums import TeamMembershipPolicy17from lp.registry.enums import TeamMembershipPolicy
@@ -36,7 +37,7 @@ def fault_catcher(func):
3637
37 def caller(self, *args, **kws):38 def caller(self, *args, **kws):
38 result = func(self, *args, **kws)39 result = func(self, *args, **kws)
39 if isinstance(result, xmlrpc_client.Fault):40 if isinstance(result, xmlrpc.client.Fault):
40 raise result41 raise result
41 else:42 else:
42 return result43 return result
diff --git a/lib/lp/registry/tests/test_mailinglistapi.py b/lib/lp/registry/tests/test_mailinglistapi.py
index 08f7f9c..be9f182 100644
--- a/lib/lp/registry/tests/test_mailinglistapi.py
+++ b/lib/lp/registry/tests/test_mailinglistapi.py
@@ -7,8 +7,8 @@ __all__ = []
77
8import email8import email
9from textwrap import dedent9from textwrap import dedent
10import xmlrpc.client
1011
11from six.moves import xmlrpc_client
12from testtools.matchers import (12from testtools.matchers import (
13 Equals,13 Equals,
14 MatchesDict,14 MatchesDict,
@@ -498,7 +498,7 @@ class MailingListAPIMessageTestCase(TestCaseWithFactory):
498 I put \xa9 in the body.498 I put \xa9 in the body.
499 """).encode('ISO-8859-1'))499 """).encode('ISO-8859-1'))
500 info = self.mailinglist_api.holdMessage(500 info = self.mailinglist_api.holdMessage(
501 'team', xmlrpc_client.Binary(message_as_bytes(message)))501 'team', xmlrpc.client.Binary(message_as_bytes(message)))
502 transaction.commit()502 transaction.commit()
503 found = self.message_approval_set.getMessageByMessageID('<\\xa9-me>')503 found = self.message_approval_set.getMessageByMessageID('<\\xa9-me>')
504 self.assertIs(True, info)504 self.assertIs(True, info)
diff --git a/lib/lp/registry/tests/test_xmlrpc.py b/lib/lp/registry/tests/test_xmlrpc.py
index dc9507b..fccd0bf 100644
--- a/lib/lp/registry/tests/test_xmlrpc.py
+++ b/lib/lp/registry/tests/test_xmlrpc.py
@@ -5,8 +5,8 @@
55
6from email import message_from_string6from email import message_from_string
7from textwrap import dedent7from textwrap import dedent
8import xmlrpc.client
89
9from six.moves import xmlrpc_client
10from zope.component import getUtility10from zope.component import getUtility
11from zope.security.proxy import removeSecurityProxy11from zope.security.proxy import removeSecurityProxy
1212
@@ -42,7 +42,7 @@ class TestCanonicalSSOApplication(TestCaseWithFactory):
4242
43 def setUp(self):43 def setUp(self):
44 super(TestCanonicalSSOApplication, self).setUp()44 super(TestCanonicalSSOApplication, self).setUp()
45 self.rpc_proxy = xmlrpc_client.ServerProxy(45 self.rpc_proxy = xmlrpc.client.ServerProxy(
46 'http://xmlrpc-private.launchpad.test:8087/canonicalsso',46 'http://xmlrpc-private.launchpad.test:8087/canonicalsso',
47 transport=XMLRPCTestTransport())47 transport=XMLRPCTestTransport())
4848
@@ -71,12 +71,12 @@ class TestCanonicalSSOApplication(TestCaseWithFactory):
71 person = self.factory.makePerson()71 person = self.factory.makePerson()
72 openid_identifier = removeSecurityProxy(72 openid_identifier = removeSecurityProxy(
73 person.account).openid_identifiers.any().identifier73 person.account).openid_identifiers.any().identifier
74 public_rpc_proxy = xmlrpc_client.ServerProxy(74 public_rpc_proxy = xmlrpc.client.ServerProxy(
75 'http://test@canonical.com:test@'75 'http://test@canonical.com:test@'
76 'xmlrpc.launchpad.test/canonicalsso',76 'xmlrpc.launchpad.test/canonicalsso',
77 transport=XMLRPCTestTransport())77 transport=XMLRPCTestTransport())
78 e = self.assertRaises(78 e = self.assertRaises(
79 xmlrpc_client.ProtocolError,79 xmlrpc.client.ProtocolError,
80 public_rpc_proxy.getPersonDetailsByOpenIDIdentifier,80 public_rpc_proxy.getPersonDetailsByOpenIDIdentifier,
81 openid_identifier)81 openid_identifier)
82 self.assertEqual(404, e.errcode)82 self.assertEqual(404, e.errcode)
@@ -88,7 +88,7 @@ class TestMailingListXMLRPC(TestCaseWithFactory):
8888
89 def setUp(self):89 def setUp(self):
90 super(TestMailingListXMLRPC, self).setUp()90 super(TestMailingListXMLRPC, self).setUp()
91 self.rpc_proxy = xmlrpc_client.ServerProxy(91 self.rpc_proxy = xmlrpc.client.ServerProxy(
92 'http://xmlrpc-private.launchpad.test:8087/mailinglists',92 'http://xmlrpc-private.launchpad.test:8087/mailinglists',
93 transport=XMLRPCTestTransport())93 transport=XMLRPCTestTransport())
9494
@@ -147,7 +147,7 @@ class TestMailingListXMLRPCMessage(TestCaseWithFactory):
147147
148 def setUp(self):148 def setUp(self):
149 super(TestMailingListXMLRPCMessage, self).setUp()149 super(TestMailingListXMLRPCMessage, self).setUp()
150 self.rpc_proxy = xmlrpc_client.ServerProxy(150 self.rpc_proxy = xmlrpc.client.ServerProxy(
151 'http://xmlrpc-private.launchpad.test:8087/mailinglists',151 'http://xmlrpc-private.launchpad.test:8087/mailinglists',
152 transport=XMLRPCTestTransport())152 transport=XMLRPCTestTransport())
153153
diff --git a/lib/lp/registry/xmlrpc/mailinglist.py b/lib/lp/registry/xmlrpc/mailinglist.py
index 829c740..4dd50eb 100644
--- a/lib/lp/registry/xmlrpc/mailinglist.py
+++ b/lib/lp/registry/xmlrpc/mailinglist.py
@@ -8,9 +8,9 @@ __all__ = [
8 ]8 ]
99
10import re10import re
11import xmlrpc.client
1112
12from six import ensure_text13from six import ensure_text
13from six.moves import xmlrpc_client
14from zope.component import getUtility14from zope.component import getUtility
15from zope.interface import implementer15from zope.interface import implementer
16from zope.security.proxy import removeSecurityProxy16from zope.security.proxy import removeSecurityProxy
@@ -244,7 +244,7 @@ class MailingListAPIView(LaunchpadXMLRPCView):
244 # non-ascii characters in the message can be safely passed across244 # non-ascii characters in the message can be safely passed across
245 # XMLRPC. For most tests though it's much more convenient to just245 # XMLRPC. For most tests though it's much more convenient to just
246 # pass 8-bit strings.246 # pass 8-bit strings.
247 if isinstance(bytes, xmlrpc_client.Binary):247 if isinstance(bytes, xmlrpc.client.Binary):
248 bytes = bytes.data248 bytes = bytes.data
249 team_name = ensure_text(team_name)249 team_name = ensure_text(team_name)
250 # Although it is illegal for an email header to have unencoded250 # Although it is illegal for an email header to have unencoded
diff --git a/lib/lp/services/authserver/tests/test_authserver.py b/lib/lp/services/authserver/tests/test_authserver.py
index a2319a3..98bdabc 100644
--- a/lib/lp/services/authserver/tests/test_authserver.py
+++ b/lib/lp/services/authserver/tests/test_authserver.py
@@ -3,8 +3,9 @@
33
4"""Tests for the internal codehosting API."""4"""Tests for the internal codehosting API."""
55
6import xmlrpc.client
7
6from pymacaroons import Macaroon8from pymacaroons import Macaroon
7from six.moves import xmlrpc_client
8from storm.sqlobject import SQLObjectNotFound9from storm.sqlobject import SQLObjectNotFound
9from testtools.matchers import (10from testtools.matchers import (
10 Equals,11 Equals,
@@ -122,7 +123,7 @@ class GetUserAndSSHKeysTests(TestCaseWithFactory):
122 new_person = self.factory.makePerson()123 new_person = self.factory.makePerson()
123 with person_logged_in(new_person):124 with person_logged_in(new_person):
124 key = self.factory.makeSSHKey(person=new_person)125 key = self.factory.makeSSHKey(person=new_person)
125 authserver = xmlrpc_client.ServerProxy(126 authserver = xmlrpc.client.ServerProxy(
126 'http://xmlrpc-private.launchpad.test:8087/authserver',127 'http://xmlrpc-private.launchpad.test:8087/authserver',
127 transport=XMLRPCTestTransport())128 transport=XMLRPCTestTransport())
128 self.assertEqual(129 self.assertEqual(
diff --git a/lib/lp/services/features/__init__.py b/lib/lp/services/features/__init__.py
index 7ee4895..e58a026 100644
--- a/lib/lp/services/features/__init__.py
+++ b/lib/lp/services/features/__init__.py
@@ -131,7 +131,7 @@ Checking flags without access to the database
131Feature flags can also be checked without access to the database by making use131Feature flags can also be checked without access to the database by making use
132of the 'getFeatureFlag' XML-RPC method.132of the 'getFeatureFlag' XML-RPC method.
133133
134 server_proxy = xmlrpc_client.ServerProxy(134 server_proxy = xmlrpc.client.ServerProxy(
135 config.launchpad.feature_flags_endpoint, allow_none=True)135 config.launchpad.feature_flags_endpoint, allow_none=True)
136 if server_proxy.getFeatureFlag(136 if server_proxy.getFeatureFlag(
137 'example_flag.enabled', ['user:' + user_name]):137 'example_flag.enabled', ['user:' + user_name]):
diff --git a/lib/lp/services/features/tests/test_xmlrpc.py b/lib/lp/services/features/tests/test_xmlrpc.py
index a2523d4..10cf61c 100644
--- a/lib/lp/services/features/tests/test_xmlrpc.py
+++ b/lib/lp/services/features/tests/test_xmlrpc.py
@@ -3,7 +3,7 @@
33
4"""Tests for FeatureFlagApplication."""4"""Tests for FeatureFlagApplication."""
55
6from six.moves import xmlrpc_client6import xmlrpc.client
77
8from lp.services import features8from lp.services import features
9from lp.services.config import config9from lp.services.config import config
@@ -82,13 +82,13 @@ class TestGetFeatureFlag(TestCaseWithFactory):
82 flag_name, ['user:' + person.name]))82 flag_name, ['user:' + person.name]))
8383
84 def test_xmlrpc_interface_unset(self):84 def test_xmlrpc_interface_unset(self):
85 sp = xmlrpc_client.ServerProxy(85 sp = xmlrpc.client.ServerProxy(
86 config.launchpad.feature_flags_endpoint,86 config.launchpad.feature_flags_endpoint,
87 transport=XMLRPCTestTransport(), allow_none=True)87 transport=XMLRPCTestTransport(), allow_none=True)
88 self.assertEqual(None, sp.getFeatureFlag(u'flag'))88 self.assertEqual(None, sp.getFeatureFlag(u'flag'))
8989
90 def test_xmlrpc_interface_set(self):90 def test_xmlrpc_interface_set(self):
91 sp = xmlrpc_client.ServerProxy(91 sp = xmlrpc.client.ServerProxy(
92 config.launchpad.feature_flags_endpoint,92 config.launchpad.feature_flags_endpoint,
93 transport=XMLRPCTestTransport(), allow_none=True)93 transport=XMLRPCTestTransport(), allow_none=True)
94 flag_name = u'flag'94 flag_name = u'flag'
diff --git a/lib/lp/services/librarianserver/db.py b/lib/lp/services/librarianserver/db.py
index 972ca8f..4ed2901 100644
--- a/lib/lp/services/librarianserver/db.py
+++ b/lib/lp/services/librarianserver/db.py
@@ -8,13 +8,13 @@ __all__ = [
8 ]8 ]
99
10import hashlib10import hashlib
11from xmlrpc.client import Fault
1112
12from pymacaroons import Macaroon13from pymacaroons import Macaroon
13from six.moves.urllib.parse import (14from six.moves.urllib.parse import (
14 quote,15 quote,
15 unquote,16 unquote,
16 )17 )
17from six.moves.xmlrpc_client import Fault
18from storm.expr import (18from storm.expr import (
19 And,19 And,
20 SQL,20 SQL,
diff --git a/lib/lp/services/tests/test_timeout.py b/lib/lp/services/tests/test_timeout.py
index 6aa31d5..b337a5d 100644
--- a/lib/lp/services/tests/test_timeout.py
+++ b/lib/lp/services/tests/test_timeout.py
@@ -7,6 +7,7 @@
7import socket7import socket
8from textwrap import dedent8from textwrap import dedent
9import threading9import threading
10import xmlrpc.client
1011
11from fixtures import (12from fixtures import (
12 MonkeyPatch,13 MonkeyPatch,
@@ -17,10 +18,7 @@ from requests.exceptions import (
17 ConnectionError,18 ConnectionError,
18 InvalidSchema,19 InvalidSchema,
19 )20 )
20from six.moves import (21from six.moves import xmlrpc_server
21 xmlrpc_client,
22 xmlrpc_server,
23 )
24from testtools.matchers import (22from testtools.matchers import (
25 ContainsDict,23 ContainsDict,
26 Equals,24 Equals,
@@ -505,7 +503,7 @@ class TestTimeout(TestCase):
505 logRequests=False)503 logRequests=False)
506 server_thread = threading.Thread(target=server.serve_2_requests)504 server_thread = threading.Thread(target=server.serve_2_requests)
507 server_thread.start()505 server_thread.start()
508 proxy = xmlrpc_client.ServerProxy(506 proxy = xmlrpc.client.ServerProxy(
509 http_server_url, transport=TransportWithTimeout())507 http_server_url, transport=TransportWithTimeout())
510 self.assertEqual('Successful test message.',508 self.assertEqual('Successful test message.',
511 proxy.echo('Successful test message.'))509 proxy.echo('Successful test message.'))
diff --git a/lib/lp/services/timeout.py b/lib/lp/services/timeout.py
index 815e08b..ff88dbe 100644
--- a/lib/lp/services/timeout.py
+++ b/lib/lp/services/timeout.py
@@ -24,6 +24,7 @@ from threading import (
24 Lock,24 Lock,
25 Thread,25 Thread,
26 )26 )
27from xmlrpc.client import Transport
2728
28from requests import (29from requests import (
29 HTTPError,30 HTTPError,
@@ -37,7 +38,6 @@ from requests_file import FileAdapter
37from requests_toolbelt.downloadutils import stream38from requests_toolbelt.downloadutils import stream
38import six39import six
39from six import reraise40from six import reraise
40from six.moves.xmlrpc_client import Transport
41from urllib3.connectionpool import (41from urllib3.connectionpool import (
42 HTTPConnectionPool,42 HTTPConnectionPool,
43 HTTPSConnectionPool,43 HTTPSConnectionPool,
diff --git a/lib/lp/services/twistedsupport/xmlrpc.py b/lib/lp/services/twistedsupport/xmlrpc.py
index 4c93d77..209f360 100644
--- a/lib/lp/services/twistedsupport/xmlrpc.py
+++ b/lib/lp/services/twistedsupport/xmlrpc.py
@@ -26,7 +26,7 @@ class BlockingProxy:
26 def __init__(self, proxy):26 def __init__(self, proxy):
27 """Construct a `BlockingProxy`.27 """Construct a `BlockingProxy`.
2828
29 :param proxy: An xmlrpc_client.ServerProxy.29 :param proxy: An xmlrpc.client.ServerProxy.
30 """30 """
31 self._proxy = proxy31 self._proxy = proxy
3232
@@ -39,7 +39,7 @@ class DeferredBlockingProxy(BlockingProxy):
3939
40 This is almost exactly like 'BlockingProxy', except that this returns40 This is almost exactly like 'BlockingProxy', except that this returns
41 Deferreds. It is guaranteed to be exactly as synchronous as the passed-in41 Deferreds. It is guaranteed to be exactly as synchronous as the passed-in
42 proxy. That means if you pass in a normal xmlrpc_client proxy you ought to42 proxy. That means if you pass in a normal xmlrpc.client proxy you ought to
43 be able to use `lp.services.twistedsupport.extract_result` to get the43 be able to use `lp.services.twistedsupport.extract_result` to get the
44 result.44 result.
45 """45 """
diff --git a/lib/lp/services/webapp/servers.py b/lib/lp/services/webapp/servers.py
index 31afcbf..eef5ede 100644
--- a/lib/lp/services/webapp/servers.py
+++ b/lib/lp/services/webapp/servers.py
@@ -4,6 +4,7 @@
4"""Definition of the internet servers that Launchpad uses."""4"""Definition of the internet servers that Launchpad uses."""
55
6import threading6import threading
7import xmlrpc.client
78
8from lazr.restful.interfaces import (9from lazr.restful.interfaces import (
9 ICollectionResource,10 ICollectionResource,
@@ -17,7 +18,6 @@ from lazr.restful.publisher import (
17from lazr.restful.utils import get_current_browser_request18from lazr.restful.utils import get_current_browser_request
18from lazr.uri import URI19from lazr.uri import URI
19import six20import six
20from six.moves import xmlrpc_client
21from six.moves.urllib.parse import parse_qs21from six.moves.urllib.parse import parse_qs
22from talisker.logs import logging_context22from talisker.logs import logging_context
23import transaction23import transaction
@@ -1403,15 +1403,15 @@ class PublicXMLRPCResponse(XMLRPCResponse):
1403 """Response type for doing public XML-RPC in Launchpad."""1403 """Response type for doing public XML-RPC in Launchpad."""
14041404
1405 def handleException(self, exc_info):1405 def handleException(self, exc_info):
1406 # If we don't have a proper xmlrpc_client.Fault, and we have1406 # If we don't have a proper xmlrpc.client.Fault, and we have
1407 # logged an OOPS, create a Fault that reports the OOPS ID to1407 # logged an OOPS, create a Fault that reports the OOPS ID to
1408 # the user.1408 # the user.
1409 exc_value = exc_info[1]1409 exc_value = exc_info[1]
1410 if not isinstance(exc_value, xmlrpc_client.Fault):1410 if not isinstance(exc_value, xmlrpc.client.Fault):
1411 request = get_current_browser_request()1411 request = get_current_browser_request()
1412 if request is not None and request.oopsid is not None:1412 if request is not None and request.oopsid is not None:
1413 exc_info = (xmlrpc_client.Fault,1413 exc_info = (xmlrpc.client.Fault,
1414 xmlrpc_client.Fault(-1, request.oopsid),1414 xmlrpc.client.Fault(-1, request.oopsid),
1415 None)1415 None)
1416 XMLRPCResponse.handleException(self, exc_info)1416 XMLRPCResponse.handleException(self, exc_info)
14171417
diff --git a/lib/lp/services/xmlrpc.py b/lib/lp/services/xmlrpc.py
index 944dec1..f34154c 100644
--- a/lib/lp/services/xmlrpc.py
+++ b/lib/lp/services/xmlrpc.py
@@ -9,16 +9,16 @@ __all__ = [
9 ]9 ]
1010
11import socket11import socket
12import xmlrpc.client
1213
13from defusedxml.xmlrpc import monkey_patch14from defusedxml.xmlrpc import monkey_patch
14from six.moves import xmlrpc_client
1515
1616
17# Protect against various XML parsing vulnerabilities.17# Protect against various XML parsing vulnerabilities.
18monkey_patch()18monkey_patch()
1919
2020
21class LaunchpadFault(xmlrpc_client.Fault):21class LaunchpadFault(xmlrpc.client.Fault):
22 """Base class for a Launchpad XMLRPC fault.22 """Base class for a Launchpad XMLRPC fault.
2323
24 Subclasses should define a unique error_code and a msg_template,24 Subclasses should define a unique error_code and a msg_template,
@@ -34,7 +34,7 @@ class LaunchpadFault(xmlrpc_client.Fault):
34 assert self.msg_template is not None, (34 assert self.msg_template is not None, (
35 "Subclasses must define msg_template.")35 "Subclasses must define msg_template.")
36 msg = self.msg_template % kw36 msg = self.msg_template % kw
37 xmlrpc_client.Fault.__init__(self, self.error_code, msg)37 xmlrpc.client.Fault.__init__(self, self.error_code, msg)
3838
39 def __eq__(self, other):39 def __eq__(self, other):
40 if not isinstance(other, LaunchpadFault):40 if not isinstance(other, LaunchpadFault):
@@ -47,19 +47,19 @@ class LaunchpadFault(xmlrpc_client.Fault):
47 return not (self == other)47 return not (self == other)
4848
4949
50class Transport(xmlrpc_client.Transport):50class Transport(xmlrpc.client.Transport):
51 """An xmlrpc_client transport that supports a timeout argument.51 """An xmlrpc.client transport that supports a timeout argument.
5252
53 Use by passing into the "transport" argument of the53 Use by passing into the "transport" argument of the
54 xmlrpc_client.ServerProxy initialization.54 xmlrpc.client.ServerProxy initialization.
55 """55 """
5656
57 def __init__(self,57 def __init__(self,
58 use_datetime=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):58 use_datetime=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
59 xmlrpc_client.Transport.__init__(self, use_datetime)59 xmlrpc.client.Transport.__init__(self, use_datetime)
60 self.timeout = timeout60 self.timeout = timeout
6161
62 def make_connection(self, host):62 def make_connection(self, host):
63 conn = xmlrpc_client.Transport.make_connection(self, host)63 conn = xmlrpc.client.Transport.make_connection(self, host)
64 conn.timeout = self.timeout64 conn.timeout = self.timeout
65 return conn65 return conn
diff --git a/lib/lp/soyuz/model/livefsbuildbehaviour.py b/lib/lp/soyuz/model/livefsbuildbehaviour.py
index acf8999..700e5c0 100644
--- a/lib/lp/soyuz/model/livefsbuildbehaviour.py
+++ b/lib/lp/soyuz/model/livefsbuildbehaviour.py
@@ -95,7 +95,7 @@ class LiveFSBuildBehaviour(BuildFarmJobBehaviourBase):
95 base_args = yield super(LiveFSBuildBehaviour, self).extraBuildArgs(95 base_args = yield super(LiveFSBuildBehaviour, self).extraBuildArgs(
96 logger=logger)96 logger=logger)
97 # Non-trivial metadata values may have been security-wrapped, which97 # Non-trivial metadata values may have been security-wrapped, which
98 # is pointless here and just gets in the way of xmlrpc_client98 # is pointless here and just gets in the way of xmlrpc.client
99 # serialisation.99 # serialisation.
100 args = dict(removeSecurityProxy(build.livefs.metadata))100 args = dict(removeSecurityProxy(build.livefs.metadata))
101 if build.metadata_override is not None:101 if build.metadata_override is not None:
diff --git a/lib/lp/soyuz/wsgi/archiveauth.py b/lib/lp/soyuz/wsgi/archiveauth.py
index 19db4a8..dc0dece 100644
--- a/lib/lp/soyuz/wsgi/archiveauth.py
+++ b/lib/lp/soyuz/wsgi/archiveauth.py
@@ -15,13 +15,13 @@ from random import SystemRandom
15import string15import string
16import sys16import sys
17import time17import time
1818from xmlrpc.client import (
19import six
20from six.moves.xmlrpc_client import (
21 Fault,19 Fault,
22 ServerProxy,20 ServerProxy,
23 )21 )
2422
23import six
24
25from lp.services.config import config25from lp.services.config import config
26from lp.services.memcache.client import memcache_client_factory26from lp.services.memcache.client import memcache_client_factory
2727
diff --git a/lib/lp/testing/xmlrpc.py b/lib/lp/testing/xmlrpc.py
index 644a22d..82ac254 100644
--- a/lib/lp/testing/xmlrpc.py
+++ b/lib/lp/testing/xmlrpc.py
@@ -9,8 +9,8 @@ __all__ = [
99
10import http.client as http_client10import http.client as http_client
11import io11import io
12import xmlrpc.client
1213
13from six.moves import xmlrpc_client
14from zope.security.management import (14from zope.security.management import (
15 endInteraction,15 endInteraction,
16 queryInteraction,16 queryInteraction,
@@ -38,7 +38,7 @@ class _FakeSocket(object):
38class TestHTTPConnection(http_client.HTTPConnection):38class TestHTTPConnection(http_client.HTTPConnection):
39 """A HTTPConnection which talks to http() instead of a real server.39 """A HTTPConnection which talks to http() instead of a real server.
4040
41 Only the methods called by xmlrpc_client are overridden.41 Only the methods called by xmlrpc.client are overridden.
42 """42 """
4343
44 _data_to_send = b''44 _data_to_send = b''
@@ -76,7 +76,7 @@ class TestHTTPConnection(http_client.HTTPConnection):
76 return response76 return response
7777
7878
79class XMLRPCTestTransport(xmlrpc_client.Transport):79class XMLRPCTestTransport(xmlrpc.client.Transport):
80 """An XMLRPC Transport which sends the requests to http()."""80 """An XMLRPC Transport which sends the requests to http()."""
8181
82 def make_connection(self, host):82 def make_connection(self, host):
diff --git a/lib/lp/xmlrpc/application.py b/lib/lp/xmlrpc/application.py
index b855323..1b23765 100644
--- a/lib/lp/xmlrpc/application.py
+++ b/lib/lp/xmlrpc/application.py
@@ -9,7 +9,8 @@ __all__ = [
9 'SelfTest',9 'SelfTest',
10 ]10 ]
1111
12from six.moves import xmlrpc_client12import xmlrpc.client
13
13from zope.component import getUtility14from zope.component import getUtility
14from zope.interface import (15from zope.interface import (
15 implementer,16 implementer,
@@ -104,7 +105,7 @@ class SelfTest(LaunchpadXMLRPCView):
104105
105 def make_fault(self):106 def make_fault(self):
106 """Returns an xmlrpc fault."""107 """Returns an xmlrpc fault."""
107 return xmlrpc_client.Fault(666, "Yoghurt and spanners.")108 return xmlrpc.client.Fault(666, "Yoghurt and spanners.")
108109
109 def concatenate(self, string1, string2):110 def concatenate(self, string1, string2):
110 """Return the concatenation of the two given strings."""111 """Return the concatenation of the two given strings."""
diff --git a/lib/lp/xmlrpc/configure.zcml b/lib/lp/xmlrpc/configure.zcml
index d387eab..a0ed00d 100644
--- a/lib/lp/xmlrpc/configure.zcml
+++ b/lib/lp/xmlrpc/configure.zcml
@@ -87,148 +87,148 @@
87 />87 />
8888
89 <class class="lp.xmlrpc.faults.BranchAlreadyRegistered">89 <class class="lp.xmlrpc.faults.BranchAlreadyRegistered">
90 <require like_class="six.moves.xmlrpc_client.Fault" />90 <require like_class="xmlrpc.client.Fault" />
91 </class>91 </class>
9292
93 <class class="lp.xmlrpc.faults.FileBugGotProductAndDistro">93 <class class="lp.xmlrpc.faults.FileBugGotProductAndDistro">
94 <require like_class="six.moves.xmlrpc_client.Fault" />94 <require like_class="xmlrpc.client.Fault" />
95 </class>95 </class>
9696
97 <class97 <class
98 class="lp.xmlrpc.faults.FileBugMissingProductOrDistribution"98 class="lp.xmlrpc.faults.FileBugMissingProductOrDistribution"
99 >99 >
100 <require like_class="six.moves.xmlrpc_client.Fault" />100 <require like_class="xmlrpc.client.Fault" />
101 </class>101 </class>
102102
103 <class class="lp.xmlrpc.faults.NoSuchDistribution">103 <class class="lp.xmlrpc.faults.NoSuchDistribution">
104 <require like_class="six.moves.xmlrpc_client.Fault" />104 <require like_class="xmlrpc.client.Fault" />
105 </class>105 </class>
106106
107 <class class="lp.xmlrpc.faults.NoSuchPackage">107 <class class="lp.xmlrpc.faults.NoSuchPackage">
108 <require like_class="six.moves.xmlrpc_client.Fault" />108 <require like_class="xmlrpc.client.Fault" />
109 </class>109 </class>
110110
111 <class class="lp.xmlrpc.faults.NoSuchProduct">111 <class class="lp.xmlrpc.faults.NoSuchProduct">
112 <require like_class="six.moves.xmlrpc_client.Fault" />112 <require like_class="xmlrpc.client.Fault" />
113 </class>113 </class>
114114
115 <class class="lp.xmlrpc.faults.NoSuchPerson">115 <class class="lp.xmlrpc.faults.NoSuchPerson">
116 <require like_class="six.moves.xmlrpc_client.Fault" />116 <require like_class="xmlrpc.client.Fault" />
117 </class>117 </class>
118118
119 <class class="lp.xmlrpc.faults.NoSuchPersonWithName">119 <class class="lp.xmlrpc.faults.NoSuchPersonWithName">
120 <require like_class="six.moves.xmlrpc_client.Fault" />120 <require like_class="xmlrpc.client.Fault" />
121 </class>121 </class>
122122
123 <class class="lp.xmlrpc.faults.NoSuchBranch">123 <class class="lp.xmlrpc.faults.NoSuchBranch">
124 <require like_class="six.moves.xmlrpc_client.Fault" />124 <require like_class="xmlrpc.client.Fault" />
125 </class>125 </class>
126126
127 <class class="lp.xmlrpc.faults.NoSuchBug">127 <class class="lp.xmlrpc.faults.NoSuchBug">
128 <require like_class="six.moves.xmlrpc_client.Fault" />128 <require like_class="xmlrpc.client.Fault" />
129 </class>129 </class>
130130
131 <class class="lp.xmlrpc.faults.RequiredParameterMissing">131 <class class="lp.xmlrpc.faults.RequiredParameterMissing">
132 <require like_class="six.moves.xmlrpc_client.Fault" />132 <require like_class="xmlrpc.client.Fault" />
133 </class>133 </class>
134134
135 <class class="lp.xmlrpc.faults.BranchCreationForbidden">135 <class class="lp.xmlrpc.faults.BranchCreationForbidden">
136 <require like_class="six.moves.xmlrpc_client.Fault" />136 <require like_class="xmlrpc.client.Fault" />
137 </class>137 </class>
138138
139 <class class="lp.xmlrpc.faults.InvalidBranchUrl">139 <class class="lp.xmlrpc.faults.InvalidBranchUrl">
140 <require like_class="six.moves.xmlrpc_client.Fault" />140 <require like_class="xmlrpc.client.Fault" />
141 </class>141 </class>
142142
143 <class class="lp.xmlrpc.faults.BranchUniqueNameConflict">143 <class class="lp.xmlrpc.faults.BranchUniqueNameConflict">
144 <require like_class="six.moves.xmlrpc_client.Fault" />144 <require like_class="xmlrpc.client.Fault" />
145 </class>145 </class>
146146
147 <class class="lp.xmlrpc.faults.NoSuchTeamMailingList">147 <class class="lp.xmlrpc.faults.NoSuchTeamMailingList">
148 <require like_class="six.moves.xmlrpc_client.Fault" />148 <require like_class="xmlrpc.client.Fault" />
149 </class>149 </class>
150150
151 <class class="lp.xmlrpc.faults.UnexpectedStatusReport">151 <class class="lp.xmlrpc.faults.UnexpectedStatusReport">
152 <require like_class="six.moves.xmlrpc_client.Fault" />152 <require like_class="xmlrpc.client.Fault" />
153 </class>153 </class>
154154
155 <class class="lp.xmlrpc.faults.BadStatus">155 <class class="lp.xmlrpc.faults.BadStatus">
156 <require like_class="six.moves.xmlrpc_client.Fault" />156 <require like_class="xmlrpc.client.Fault" />
157 </class>157 </class>
158158
159 <class class="lp.xmlrpc.faults.NoLinkedBranch">159 <class class="lp.xmlrpc.faults.NoLinkedBranch">
160 <require like_class="six.moves.xmlrpc_client.Fault" />160 <require like_class="xmlrpc.client.Fault" />
161 </class>161 </class>
162162
163 <class class="lp.xmlrpc.faults.NoSuchProductSeries">163 <class class="lp.xmlrpc.faults.NoSuchProductSeries">
164 <require like_class="six.moves.xmlrpc_client.Fault" />164 <require like_class="xmlrpc.client.Fault" />
165 </class>165 </class>
166166
167 <class class="lp.xmlrpc.faults.InvalidBranchIdentifier">167 <class class="lp.xmlrpc.faults.InvalidBranchIdentifier">
168 <require like_class="six.moves.xmlrpc_client.Fault" />168 <require like_class="xmlrpc.client.Fault" />
169 </class>169 </class>
170170
171 <class class="lp.xmlrpc.faults.BranchNameInUse">171 <class class="lp.xmlrpc.faults.BranchNameInUse">
172 <require like_class="six.moves.xmlrpc_client.Fault" />172 <require like_class="xmlrpc.client.Fault" />
173 </class>173 </class>
174174
175 <class class="lp.xmlrpc.faults.CannotHaveLinkedBranch">175 <class class="lp.xmlrpc.faults.CannotHaveLinkedBranch">
176 <require like_class="six.moves.xmlrpc_client.Fault" />176 <require like_class="xmlrpc.client.Fault" />
177 </class>177 </class>
178178
179 <class class="lp.xmlrpc.faults.InvalidProductName">179 <class class="lp.xmlrpc.faults.InvalidProductName">
180 <require like_class="six.moves.xmlrpc_client.Fault" />180 <require like_class="xmlrpc.client.Fault" />
181 </class>181 </class>
182182
183 <class class="lp.xmlrpc.faults.NotInTeam">183 <class class="lp.xmlrpc.faults.NotInTeam">
184 <require like_class="six.moves.xmlrpc_client.Fault" />184 <require like_class="xmlrpc.client.Fault" />
185 </class>185 </class>
186186
187 <class class="lp.xmlrpc.faults.InvalidBranchName">187 <class class="lp.xmlrpc.faults.InvalidBranchName">
188 <require like_class="six.moves.xmlrpc_client.Fault" />188 <require like_class="xmlrpc.client.Fault" />
189 </class>189 </class>
190190
191 <class class="lp.xmlrpc.faults.NoBranchWithID">191 <class class="lp.xmlrpc.faults.NoBranchWithID">
192 <require like_class="six.moves.xmlrpc_client.Fault" />192 <require like_class="xmlrpc.client.Fault" />
193 </class>193 </class>
194194
195 <class class="lp.xmlrpc.faults.NoUrlForBranch">195 <class class="lp.xmlrpc.faults.NoUrlForBranch">
196 <require like_class="six.moves.xmlrpc_client.Fault" />196 <require like_class="xmlrpc.client.Fault" />
197 </class>197 </class>
198198
199 <class class="lp.xmlrpc.faults.PathTranslationError">199 <class class="lp.xmlrpc.faults.PathTranslationError">
200 <require like_class="six.moves.xmlrpc_client.Fault" />200 <require like_class="xmlrpc.client.Fault" />
201 </class>201 </class>
202202
203 <class class="lp.xmlrpc.faults.InvalidPath">203 <class class="lp.xmlrpc.faults.InvalidPath">
204 <require like_class="six.moves.xmlrpc_client.Fault" />204 <require like_class="xmlrpc.client.Fault" />
205 </class>205 </class>
206206
207 <class class="lp.xmlrpc.faults.PermissionDenied">207 <class class="lp.xmlrpc.faults.PermissionDenied">
208 <require like_class="six.moves.xmlrpc_client.Fault" />208 <require like_class="xmlrpc.client.Fault" />
209 </class>209 </class>
210210
211 <class class="lp.xmlrpc.faults.NotFound">211 <class class="lp.xmlrpc.faults.NotFound">
212 <require like_class="six.moves.xmlrpc_client.Fault" />212 <require like_class="xmlrpc.client.Fault" />
213 </class>213 </class>
214214
215 <class class="lp.xmlrpc.faults.InvalidBranchUniqueName">215 <class class="lp.xmlrpc.faults.InvalidBranchUniqueName">
216 <require like_class="six.moves.xmlrpc_client.Fault" />216 <require like_class="xmlrpc.client.Fault" />
217 </class>217 </class>
218218
219 <class class="lp.xmlrpc.faults.NoSuchDistroSeries">219 <class class="lp.xmlrpc.faults.NoSuchDistroSeries">
220 <require like_class="six.moves.xmlrpc_client.Fault" />220 <require like_class="xmlrpc.client.Fault" />
221 </class>221 </class>
222222
223 <class class="lp.xmlrpc.faults.NoSuchSourcePackageName">223 <class class="lp.xmlrpc.faults.NoSuchSourcePackageName">
224 <require like_class="six.moves.xmlrpc_client.Fault" />224 <require like_class="xmlrpc.client.Fault" />
225 </class>225 </class>
226226
227 <class class="lp.xmlrpc.faults.InvalidSourcePackageName">227 <class class="lp.xmlrpc.faults.InvalidSourcePackageName">
228 <require like_class="six.moves.xmlrpc_client.Fault" />228 <require like_class="xmlrpc.client.Fault" />
229 </class>229 </class>
230230
231 <class class="lp.xmlrpc.faults.Unauthorized">231 <class class="lp.xmlrpc.faults.Unauthorized">
232 <require like_class="six.moves.xmlrpc_client.Fault" />232 <require like_class="xmlrpc.client.Fault" />
233 </class>233 </class>
234</configure>234</configure>
diff --git a/lib/lp/xmlrpc/helpers.py b/lib/lp/xmlrpc/helpers.py
index e990af9..f2c7397 100644
--- a/lib/lp/xmlrpc/helpers.py
+++ b/lib/lp/xmlrpc/helpers.py
@@ -7,7 +7,8 @@ __all__ = [
7 'return_fault',7 'return_fault',
8 ]8 ]
99
10from six.moves.xmlrpc_client import Fault10from xmlrpc.client import Fault
11
11from twisted.python.util import mergeFunctionMetadata12from twisted.python.util import mergeFunctionMetadata
1213
1314
diff --git a/lib/lp/xmlrpc/tests/test_private_xmlrpc.py b/lib/lp/xmlrpc/tests/test_private_xmlrpc.py
index c20d180..7215a23 100644
--- a/lib/lp/xmlrpc/tests/test_private_xmlrpc.py
+++ b/lib/lp/xmlrpc/tests/test_private_xmlrpc.py
@@ -4,7 +4,8 @@
4"""Private XMLRPC tests.4"""Private XMLRPC tests.
5"""5"""
66
7from six.moves import xmlrpc_client7import xmlrpc.client
8
8from zope.component import getUtility9from zope.component import getUtility
910
10from lp.services.verification.interfaces.logintoken import ILoginTokenSet11from lp.services.verification.interfaces.logintoken import ILoginTokenSet
@@ -30,14 +31,14 @@ class TestPrivateXMLRPC(TestCase):
30 private_root = 'http://xmlrpc-private.launchpad.test:8087/'31 private_root = 'http://xmlrpc-private.launchpad.test:8087/'
3132
32 def get_public_proxy(self, path):33 def get_public_proxy(self, path):
33 """Get an xmlrpc_client.ServerProxy pointing at the public URL"""34 """Get an xmlrpc.client.ServerProxy pointing at the public URL"""
34 return xmlrpc_client.ServerProxy(35 return xmlrpc.client.ServerProxy(
35 self.public_root + path,36 self.public_root + path,
36 transport=XMLRPCTestTransport())37 transport=XMLRPCTestTransport())
3738
38 def get_private_proxy(self, path):39 def get_private_proxy(self, path):
39 """Get an xmlrpc_client.ServerProxy pointing at the private URL"""40 """Get an xmlrpc.client.ServerProxy pointing at the private URL"""
40 return xmlrpc_client.ServerProxy(41 return xmlrpc.client.ServerProxy(
41 self.private_root + path,42 self.private_root + path,
42 transport=XMLRPCTestTransport())43 transport=XMLRPCTestTransport())
4344
@@ -47,7 +48,7 @@ class TestPrivateXMLRPC(TestCase):
47 not available on the external XML-RPC port.48 not available on the external XML-RPC port.
48 """49 """
49 external_api = self.get_public_proxy('mailinglists/')50 external_api = self.get_public_proxy('mailinglists/')
50 e = self.assertRaises(xmlrpc_client.ProtocolError,51 e = self.assertRaises(xmlrpc.client.ProtocolError,
51 external_api.getPendingActions)52 external_api.getPendingActions)
52 self.assertEqual(404, e.errcode)53 self.assertEqual(404, e.errcode)
5354
@@ -77,7 +78,7 @@ class TestPrivateXMLRPC(TestCase):
77 internal_api = self.get_private_proxy('bugs/')78 internal_api = self.get_private_proxy('bugs/')
78 bug_dict = dict(79 bug_dict = dict(
79 product='firefox', summary='the summary', comment='the comment')80 product='firefox', summary='the summary', comment='the comment')
80 e = self.assertRaises(xmlrpc_client.ProtocolError,81 e = self.assertRaises(xmlrpc.client.ProtocolError,
81 internal_api.filebug, bug_dict)82 internal_api.filebug, bug_dict)
82 self.assertEqual(404, e.errcode)83 self.assertEqual(404, e.errcode)
8384
diff --git a/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py b/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py
index 4c005eb..9f0d528 100644
--- a/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py
+++ b/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py
@@ -4,7 +4,8 @@
4"""XMLRPC self-test api.4"""XMLRPC self-test api.
5"""5"""
66
7from six.moves import xmlrpc_client7import xmlrpc.client
8
8from zope.component import getUtility9from zope.component import getUtility
910
10from lp.services.webapp.interfaces import ILaunchBag11from lp.services.webapp.interfaces import ILaunchBag
@@ -27,11 +28,11 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
27 layer = LaunchpadFunctionalLayer28 layer = LaunchpadFunctionalLayer
2829
29 def make_proxy(self):30 def make_proxy(self):
30 return xmlrpc_client.ServerProxy(31 return xmlrpc.client.ServerProxy(
31 'http://xmlrpc.launchpad.test/', transport=XMLRPCTestTransport())32 'http://xmlrpc.launchpad.test/', transport=XMLRPCTestTransport())
3233
33 def make_logged_in_proxy(self):34 def make_logged_in_proxy(self):
34 return xmlrpc_client.ServerProxy(35 return xmlrpc.client.ServerProxy(
35 'http://test@canonical.com:test@xmlrpc.launchpad.test/',36 'http://test@canonical.com:test@xmlrpc.launchpad.test/',
36 transport=XMLRPCTestTransport())37 transport=XMLRPCTestTransport())
3738
@@ -46,17 +47,17 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
46 self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault))47 self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault))
4748
48 def test_custom_transport(self):49 def test_custom_transport(self):
49 """We can test our XMLRPC APIs using xmlrpc_client, using a custom50 """We can test our XMLRPC APIs using xmlrpc.client, using a custom
50 Transport which talks with the publisher directly.51 Transport which talks with the publisher directly.
51 """52 """
52 selftest = self.make_proxy()53 selftest = self.make_proxy()
53 self.assertEqual('foo bar', selftest.concatenate('foo', 'bar'))54 self.assertEqual('foo bar', selftest.concatenate('foo', 'bar'))
54 fault = self.assertRaises(xmlrpc_client.Fault, selftest.make_fault)55 fault = self.assertRaises(xmlrpc.client.Fault, selftest.make_fault)
55 self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault))56 self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault))
5657
57 def test_unexpected_exception(self):58 def test_unexpected_exception(self):
58 """Sometimes an XML-RPC method will be buggy, and raise an exception59 """Sometimes an XML-RPC method will be buggy, and raise an exception
59 other than xmlrpc_client.Fault. We have such a method on the self60 other than xmlrpc.client.Fault. We have such a method on the self
60 test view.61 test view.
61 """62 """
62 selftestview = SelfTest('somecontext', 'somerequest')63 selftestview = SelfTest('somecontext', 'somerequest')
@@ -69,7 +70,7 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
69 one was generated):70 one was generated):
70 """71 """
71 selftest = self.make_proxy()72 selftest = self.make_proxy()
72 e = self.assertRaises(xmlrpc_client.Fault, selftest.raise_exception)73 e = self.assertRaises(xmlrpc.client.Fault, selftest.raise_exception)
73 self.assertStartsWith(str(e), "<Fault -1: 'OOPS-")74 self.assertStartsWith(str(e), "<Fault -1: 'OOPS-")
7475
75 def test_anonymous_authentication(self):76 def test_anonymous_authentication(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: