/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/lp_registration.py

  • Committer: Jelmer Vernooij
  • Date: 2017-02-05 16:17:03 UTC
  • mto: (6621.2.1 py3)
  • mto: This revision was merged to the branch mainline in revision 6624.
  • Revision ID: jelmer@jelmer.uk-20170205161703-le42ds13b6ka1ajn
Require python 2.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
 
18
20
import os
19
21
import socket
54
56
class XMLRPCTransport(xmlrpclib.Transport):
55
57
 
56
58
    def __init__(self, scheme):
57
 
        # In python2.4 xmlrpclib.Transport is a old-style class, and does not
58
 
        # define __init__, so we check first
59
 
        init = getattr(xmlrpclib.Transport, '__init__', None)
60
 
        if init is not None:
61
 
            init(self)
 
59
        xmlrpclib.Transport.__init__(self)
62
60
        self._scheme = scheme
63
61
        self._opener = _urllib2_wrappers.Opener()
64
62
        self.verbose = 0
86
84
 
87
85
    LAUNCHPAD_DOMAINS = {
88
86
        'production': 'launchpad.net',
89
 
        'edge': 'edge.launchpad.net',
90
87
        'staging': 'staging.launchpad.net',
 
88
        'qastaging': 'qastaging.launchpad.net',
91
89
        'demo': 'demo.launchpad.net',
92
90
        'dev': 'launchpad.dev',
93
91
        }
98
96
    for instance, domain in LAUNCHPAD_DOMAINS.iteritems():
99
97
        LAUNCHPAD_INSTANCE[instance] = 'https://xmlrpc.%s/bazaar/' % domain
100
98
 
101
 
    # We use edge as the default because:
102
 
    # Beta users get redirected to it
103
 
    # All users can use it
104
 
    # There is a bug in the launchpad side where redirection causes an OOPS.
105
 
    DEFAULT_INSTANCE = 'edge'
 
99
    # We use production as the default because edge has been deprecated circa
 
100
    # 2010-11 (see bug https://bugs.launchpad.net/bzr/+bug/583667)
 
101
    DEFAULT_INSTANCE = 'production'
106
102
    DEFAULT_SERVICE_URL = LAUNCHPAD_INSTANCE[DEFAULT_INSTANCE]
107
103
 
108
104
    transport = None
168
164
            # the url?  perhaps a bit more secure against accidentally
169
165
            # revealing it.  std66 s3.2.1 discourages putting the
170
166
            # password in the url.
171
 
            hostinfo = '%s:%s@%s' % (urllib.quote(self.registrant_email),
172
 
                                     urllib.quote(self.registrant_password),
 
167
            hostinfo = '%s:%s@%s' % (urlutils.quote(self.registrant_email),
 
168
                                     urlutils.quote(self.registrant_password),
173
169
                                     hostinfo)
174
170
            url = urlunsplit((scheme, hostinfo, path, '', ''))
175
171
        else:
196
192
        method = getattr(proxy, method_name)
197
193
        try:
198
194
            result = method(*method_params)
199
 
        except xmlrpclib.ProtocolError, e:
 
195
        except xmlrpclib.ProtocolError as e:
200
196
            if e.errcode == 301:
201
197
                # TODO: This can give a ProtocolError representing a 301 error, whose
202
198
                # e.headers['location'] tells where to go and e.errcode==301; should
209
205
                # TODO: print more headers to help in tracking down failures
210
206
                raise errors.BzrError("xmlrpc protocol error connecting to %s: %s %s"
211
207
                        % (self.service_url, e.errcode, e.errmsg))
212
 
        except socket.gaierror, e:
 
208
        except socket.gaierror as e:
213
209
            raise errors.ConnectionError(
214
210
                "Could not resolve '%s'" % self.domain,
215
211
                orig_error=e)
231
227
            resolve = _request_factory(path)
232
228
            try:
233
229
                result = resolve.submit(self)
234
 
            except xmlrpclib.Fault, fault:
 
230
            except xmlrpclib.Fault as fault:
235
231
                raise errors.InvalidURL(branch_url, str(fault))
236
232
            branch_url = result['urls'][0]
237
233
            path = urlsplit(branch_url)[2]