From e4e8f156bd2e9c259addb0c56e2967f9ab747772 Mon Sep 17 00:00:00 2001 From: Michael Bienia Date: Sat, 20 Mar 2010 18:27:31 +0100 Subject: [PATCH] * ubuntutools/lp/lpapicache.py, ubuntutools/lp/libsupport.py: Add support for different LP API versions. * ubuntutools/lp/__init__.py: Set the '1.0' LP API version as default. * massfile: Updated to 1.0 LP API. --- debian/changelog | 6 +++++- massfile | 5 +++-- ubuntutools/lp/__init__.py | 1 + ubuntutools/lp/libsupport.py | 6 +++--- ubuntutools/lp/lpapicache.py | 26 +++++++++++++------------- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9cb1570..77988e2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,8 +3,12 @@ ubuntu-dev-tools (0.97) UNRELEASED; urgency=low [ Michael Bienia ] * lp-shell: Support all to the launchpadlib Python module known service names. + * ubuntutools/lp/lpapicache.py, ubuntutools/lp/libsupport.py: Add support + for different LP API versions. + * ubuntutools/lp/__init__.py: Set the '1.0' LP API version as default. + * massfile: Updated to 1.0 LP API. - -- Michael Bienia Thu, 18 Mar 2010 11:01:21 +0100 + -- Michael Bienia Sat, 20 Mar 2010 18:26:49 +0100 ubuntu-dev-tools (0.96) lucid; urgency=low diff --git a/massfile b/massfile index e01a537..d4fa88f 100755 --- a/massfile +++ b/massfile @@ -106,12 +106,13 @@ def file_bug(config): status = config["status"].capitalize() else: status = "Confirmed" - task.transitionToStatus(status=status) + task.status = status assignee = config["assignee"] if assignee: assignee_url = "%s~%s" %(launchpad._root_uri, assignee) - bug.transitionToAssignee(assignee=assignee_url) + task.assignee = assignee_url + task.lp_save() except: "Bug for '%s' was not filed." % config["sourcepackage"] diff --git a/ubuntutools/lp/__init__.py b/ubuntutools/lp/__init__.py index e3aabb3..9f8b1ff 100644 --- a/ubuntutools/lp/__init__.py +++ b/ubuntutools/lp/__init__.py @@ -3,3 +3,4 @@ ## service = 'edge' +api_version = '1.0' diff --git a/ubuntutools/lp/libsupport.py b/ubuntutools/lp/libsupport.py index c42753e..36fb856 100644 --- a/ubuntutools/lp/libsupport.py +++ b/ubuntutools/lp/libsupport.py @@ -37,7 +37,7 @@ except: Credentials = None Launchpad = None -from ubuntutools.lp import service +from ubuntutools.lp import (service, api_version) def find_credentials(consumer, files, level=None): """ search for credentials matching 'consumer' in path for given access level. """ @@ -79,7 +79,7 @@ def get_launchpad(consumer, server=service, cache=None, cred_file=None, level=None): credentials = get_credentials(consumer, cred_file, level) cache = cache or os.environ.get("LPCACHE", None) - return Launchpad(credentials, server, cache) + return Launchpad(credentials, server, cache, version=api_version) def query_to_dict(query_string): result = dict() @@ -106,7 +106,7 @@ def translate_web_api(url, launchpad): return url def translate_api_web(self_url): - return self_url.replace("api.", "").replace("beta/", "") + return self_url.replace("api.", "").replace("%s/" % (api_version), "") LEVEL = { 0: "UNAUTHORIZED", diff --git a/ubuntutools/lp/lpapicache.py b/ubuntutools/lp/lpapicache.py index 8e53528..b6aef8f 100644 --- a/ubuntutools/lp/lpapicache.py +++ b/ubuntutools/lp/lpapicache.py @@ -32,7 +32,7 @@ from launchpadlib.uris import lookup_service_root from lazr.restfulclient.resource import Entry import ubuntutools.lp.libsupport as libsupport -from ubuntutools.lp import service +from ubuntutools.lp import (service, api_version) from ubuntutools.lp.udtexceptions import * __all__ = [ @@ -96,7 +96,7 @@ class BaseWrapper(object): resource_type = None # it's a base class after all def __new__(cls, data): - if isinstance(data, basestring) and data.startswith(lookup_service_root(service) + 'beta/'): + if isinstance(data, basestring) and data.startswith('%s%s/' % (lookup_service_root(service), api_version)): # looks like a LP API URL # check if it's already cached cached = cls._cache.get(data) @@ -151,7 +151,7 @@ class Distribution(BaseWrapper): ''' Wrapper class around a LP distribution object. ''' - resource_type = lookup_service_root(service) + 'beta/#distribution' + resource_type = lookup_service_root(service) + api_version + '/#distribution' def __init__(self, *args): # Don't share _series and _archives between different Distributions @@ -214,7 +214,7 @@ class Distribution(BaseWrapper): self._series[series.name] = series self._series[series.version] = series except HTTPError: - raise SeriesNotFoundException("Error: Release '%s' is unknown in '%s'." % (name_or_version, self.display_name)) + raise SeriesNotFoundException("Release '%s' is unknown in '%s'." % (name_or_version, self.display_name)) return self._series[name_or_version] def getDevelopmentSeries(self): @@ -233,14 +233,14 @@ class DistroSeries(BaseWrapper): ''' Wrapper class around a LP distro series object. ''' - resource_type = lookup_service_root(service) + 'beta/#distro_series' + resource_type = lookup_service_root(service) + api_version + '/#distro_series' class Archive(BaseWrapper): ''' Wrapper class around a LP archive object. ''' - resource_type = lookup_service_root(service) + 'beta/#archive' + resource_type = lookup_service_root(service) + api_version + '/#archive' def __init__(self, *args): # Don't share _srcpkgs between different Archives @@ -301,7 +301,7 @@ class SourcePackagePublishingHistory(BaseWrapper): ''' Wrapper class around a LP source package object. ''' - resource_type = lookup_service_root(service) + 'beta/#source_package_publishing_history' + resource_type = lookup_service_root(service) + api_version + '/#source_package_publishing_history' def __init__(self, *args): # Don't share _builds between different SourcePackagePublishingHistory objects @@ -334,7 +334,7 @@ class SourcePackagePublishingHistory(BaseWrapper): def getBuildStates(self, archs): res = list() - + if not self._builds: self._fetch_builds() @@ -402,8 +402,8 @@ class PersonTeam(BaseWrapper): __metaclass__ = MetaPersonTeam resource_type = ( - lookup_service_root(service) + 'beta/#person', - lookup_service_root(service) + 'beta/#team', + lookup_service_root(service) + api_version + '/#person', + lookup_service_root(service) + api_version + '/#team', ) def __init__(self, *args): @@ -434,7 +434,7 @@ class PersonTeam(BaseWrapper): def isLpTeamMember(self, team): ''' Checks if the user is a member of a certain team on Launchpad. - + Returns True if the user is a member of the team otherwise False. ''' return any(t.name == team for t in self.super_teams) @@ -493,7 +493,7 @@ class Build(BaseWrapper): ''' Wrapper class around a build object. ''' - resource_type = lookup_service_root(service) + 'beta/#build' + resource_type = lookup_service_root(service) + api_version + '/#build' def __str__(self): return u'%s: %s' % (self.arch_tag, self.buildstate) @@ -515,4 +515,4 @@ class DistributionSourcePackage(BaseWrapper): ''' Caching class for distribution_source_package objects. ''' - resource_type = lookup_service_root(service) + 'beta/#distribution_source_package' + resource_type = lookup_service_root(service) + api_version + '/#distribution_source_package'