mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 16:11:15 +00:00
Replace translate_service() from ubuntutools.lp.libsupport with calls to
lookup_service_root() from launchpadlib.uris.
This commit is contained in:
parent
a33a5c106b
commit
4f21ae1cd0
@ -22,6 +22,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser, make_option
|
from optparse import OptionParser, make_option
|
||||||
|
from launchpadlib.uris import lookup_service_root
|
||||||
from ubuntutools.lp.libsupport import *
|
from ubuntutools.lp.libsupport import *
|
||||||
|
|
||||||
class CmdOptions(OptionParser):
|
class CmdOptions(OptionParser):
|
||||||
@ -77,7 +78,7 @@ class CmdOptions(OptionParser):
|
|||||||
optional_options = given_options - set(sum(self.TOOLS[tool], ()))
|
optional_options = given_options - set(sum(self.TOOLS[tool], ()))
|
||||||
if optional_options:
|
if optional_options:
|
||||||
self.error("The following options are not allowed for this tool: %s" %", ".join(optional_options))
|
self.error("The following options are not allowed for this tool: %s" %", ".join(optional_options))
|
||||||
options.service = translate_service(options.service)
|
options.service = lookup_service_root(options.service)
|
||||||
if options.level in LEVEL:
|
if options.level in LEVEL:
|
||||||
options.level = LEVEL[options.level]
|
options.level = LEVEL[options.level]
|
||||||
elif options.level.upper() in LEVEL.values():
|
elif options.level.upper() in LEVEL.values():
|
||||||
|
@ -28,7 +28,7 @@ import httplib2
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from launchpadlib.credentials import Credentials
|
from launchpadlib.credentials import Credentials
|
||||||
from launchpadlib.launchpad import Launchpad, STAGING_SERVICE_ROOT, EDGE_SERVICE_ROOT
|
from launchpadlib.launchpad import Launchpad
|
||||||
from launchpadlib.errors import HTTPError
|
from launchpadlib.errors import HTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print "Unable to import launchpadlib module, is python-launchpadlib installed?"
|
print "Unable to import launchpadlib module, is python-launchpadlib installed?"
|
||||||
@ -37,6 +37,8 @@ except:
|
|||||||
Credentials = None
|
Credentials = None
|
||||||
Launchpad = None
|
Launchpad = None
|
||||||
|
|
||||||
|
from ubuntutools.lp import service
|
||||||
|
|
||||||
def find_credentials(consumer, files, level=None):
|
def find_credentials(consumer, files, level=None):
|
||||||
""" search for credentials matching 'consumer' in path for given access level. """
|
""" search for credentials matching 'consumer' in path for given access level. """
|
||||||
if Credentials is None:
|
if Credentials is None:
|
||||||
@ -73,7 +75,7 @@ def get_credentials(consumer, cred_file=None, level=None):
|
|||||||
|
|
||||||
return find_credentials(consumer, files, level)
|
return find_credentials(consumer, files, level)
|
||||||
|
|
||||||
def get_launchpad(consumer, server=EDGE_SERVICE_ROOT, cache=None,
|
def get_launchpad(consumer, server=service, cache=None,
|
||||||
cred_file=None, level=None):
|
cred_file=None, level=None):
|
||||||
credentials = get_credentials(consumer, cred_file, level)
|
credentials = get_credentials(consumer, cred_file, level)
|
||||||
cache = cache or os.environ.get("LPCACHE", None)
|
cache = cache or os.environ.get("LPCACHE", None)
|
||||||
@ -140,14 +142,3 @@ def approve_application(credentials, email, password, level, web_root,
|
|||||||
raise HTTPError(response, content)
|
raise HTTPError(response, content)
|
||||||
credentials.exchange_request_token_for_access_token(web_root)
|
credentials.exchange_request_token_for_access_token(web_root)
|
||||||
return credentials
|
return credentials
|
||||||
|
|
||||||
def translate_service(service):
|
|
||||||
_service = service.lower()
|
|
||||||
if _service in (STAGING_SERVICE_ROOT, EDGE_SERVICE_ROOT):
|
|
||||||
return _service
|
|
||||||
elif _service == "edge":
|
|
||||||
return EDGE_SERVICE_ROOT
|
|
||||||
elif _service == "staging":
|
|
||||||
return STAGING_SERVICE_ROOT
|
|
||||||
else:
|
|
||||||
raise ValueError("unknown service '%s'" %service)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user