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/')
62
52
# Declare the minimum version of launchpadlib that we need in order to work.
63
53
# 1.5.1 is the version of launchpadlib packaged in Ubuntu 9.10, the most
84
74
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.
87
90
LAUNCHPAD_API_URLS = {
88
'production': LPNET_SERVICE_ROOT,
89
'qastaging': QASTAGING_SERVICE_ROOT,
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'),
90
95
'staging': STAGING_SERVICE_ROOT,
91
'dev': 'https://api.launchpad.dev/beta/',
96
'dev': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
199
205
if str(launchpad._root_uri) == STAGING_SERVICE_ROOT:
200
206
return url.replace('bazaar.launchpad.net',
201
207
'bazaar.staging.launchpad.net')
202
elif str(launchpad._root_uri) == QASTAGING_SERVICE_ROOT:
208
elif str(launchpad._root_uri) == LAUNCHPAD_API_URLS['qastaging']:
203
209
return url.replace('bazaar.launchpad.net',
204
210
'bazaar.qastaging.launchpad.net')