47
47
STAGING_SERVICE_ROOT,
51
from launchpadlib import uris
53
# Create a minimal object so the getattr() calls below fail gently and
54
# provide default values
57
LPNET_SERVICE_ROOT = getattr(uris, 'LPNET_SERVICE_ROOT',
58
'https://api.launchpad.net/beta/')
59
QASTAGING_SERVICE_ROOT = getattr(uris, 'QASTAGING_SERVICE_ROOT',
60
'https://api.qastaging.launchpad.net/')
52
62
# Declare the minimum version of launchpadlib that we need in order to work.
53
63
# 1.5.1 is the version of launchpadlib packaged in Ubuntu 9.10, the most
74
84
installed_version, installed_version)
77
# The older versions of launchpadlib only provided service root constants for
78
# edge and staging, whilst newer versions drop edge. Therefore service root
79
# URIs for which we do not always have constants are derived from the staging
80
# one, which does always exist.
82
# It is necessary to derive, rather than use hardcoded URIs because
83
# launchpadlib <= 1.5.4 requires service root URIs that end in a path of
84
# /beta/, whilst launchpadlib >= 1.5.5 requires service root URIs with no path
87
# Once we have a hard dependency on launchpadlib >= 1.5.4 we can replace all of
88
# bzr's local knowledge of individual Launchpad instances with use of the
89
# launchpadlib.uris module.
90
87
LAUNCHPAD_API_URLS = {
91
'production': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
93
'qastaging': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
94
'api.qastaging.launchpad.net'),
88
'production': LPNET_SERVICE_ROOT,
89
'qastaging': QASTAGING_SERVICE_ROOT,
95
90
'staging': STAGING_SERVICE_ROOT,
96
'dev': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
91
'dev': 'https://api.launchpad.dev/beta/',
205
199
if str(launchpad._root_uri) == STAGING_SERVICE_ROOT:
206
200
return url.replace('bazaar.launchpad.net',
207
201
'bazaar.staging.launchpad.net')
208
elif str(launchpad._root_uri) == LAUNCHPAD_API_URLS['qastaging']:
202
elif str(launchpad._root_uri) == QASTAGING_SERVICE_ROOT:
209
203
return url.replace('bazaar.launchpad.net',
210
204
'bazaar.qastaging.launchpad.net')