mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
Merge changes from my devel branch
This commit is contained in:
commit
a0f10bb410
10
buildd
10
buildd
@ -27,7 +27,7 @@ import sys
|
||||
from optparse import OptionGroup
|
||||
from optparse import OptionParser
|
||||
from ubuntutools.lp.udtexceptions import SeriesNotFoundException, PackageNotFoundException
|
||||
from ubuntutools.lp.lpapiwrapper import LpApiWrapper
|
||||
from ubuntutools.lp.lpapicache import Distribution, PersonTeam
|
||||
|
||||
# Usage.
|
||||
usage = "%prog <srcpackage> <release> <operation>\n\n"
|
||||
@ -124,7 +124,7 @@ if not options.batch:
|
||||
sys.exit(1)
|
||||
|
||||
# Get the ubuntu archive
|
||||
ubuntu_archive = LpApiWrapper.getUbuntuDistribution().getArchive()
|
||||
ubuntu_archive = Distribution('ubuntu').getArchive()
|
||||
# Get list of published sources for package in question.
|
||||
try:
|
||||
sources = ubuntu_archive.getSourcePackage(package, release, pocket)
|
||||
@ -140,7 +140,7 @@ if not options.batch:
|
||||
|
||||
# Operations that are remaining may only be done by Ubuntu developers (retry)
|
||||
# or buildd admins (rescore). Check if the proper permissions are in place.
|
||||
me = LpApiWrapper.getMe()
|
||||
me = PersonTeam.getMe()
|
||||
if op == "rescore": necessaryPrivs = me.isLpTeamMember('launchpad-buildd-admins')
|
||||
if op == "retry": necessaryPrivs = me.canUploadPackage(
|
||||
ubuntu_archive, sources.getPackageName(), sources.getComponent())
|
||||
@ -210,8 +210,8 @@ if release and '-' in release:
|
||||
print 'Unknown pocket: %s' % pocket
|
||||
sys.exit(1)
|
||||
|
||||
ubuntu_archive = LpApiWrapper.getUbuntuDistribution().getArchive()
|
||||
me = LpApiWrapper.getMe()
|
||||
ubuntu_archive = Distribution('ubuntu').getArchive()
|
||||
me = PersonTeam.getMe()
|
||||
|
||||
# Check permisions (part 1): Rescoring can only be done by buildd admins
|
||||
can_rescore = options.priority and me.isLpTeamMember('launchpad-buildd-admins') or False
|
||||
|
@ -33,7 +33,7 @@ import urllib2
|
||||
from optparse import OptionParser
|
||||
|
||||
# ubuntu-dev-tools modules.
|
||||
from ubuntutools.lp.lpapiwrapper import LpApiWrapper
|
||||
from ubuntutools.lp.lpapicache import Distribution
|
||||
from ubuntutools.lp.udtexceptions import SeriesNotFoundException, PackageNotFoundException
|
||||
|
||||
if not os.path.exists("/usr/bin/dget"):
|
||||
@ -76,12 +76,12 @@ if __name__ == '__main__':
|
||||
if len(args) == 2: # Custom distribution specified.
|
||||
release = str(args[1]).lower()
|
||||
else:
|
||||
release = os.getenv('DIST') or LpApiWrapper.getUbuntuDistribution().getDevelopmentSeries().name
|
||||
release = os.getenv('DIST') or Distribution('ubuntu').getDevelopmentSeries().name
|
||||
|
||||
# Arguments are correct, proceed.
|
||||
# Check that the Ubuntu release and package specified exists.
|
||||
try:
|
||||
LpApiWrapper.getUbuntuSourcePackage(package, release)
|
||||
Distribution('ubuntu').getArchive().getSourcePackage(package, release)
|
||||
except (SeriesNotFoundException, PackageNotFoundException), e:
|
||||
print e
|
||||
sys.exit(1)
|
||||
|
12
requestsync
12
requestsync
@ -5,7 +5,7 @@
|
||||
# Authors:
|
||||
# Martin Pitt <martin.pitt@ubuntu.com>
|
||||
# Steve Kowalik <stevenk@ubuntu.com>
|
||||
# Michael Bienia <geser@ubuntu.com> (python-launchpad-bugs support)
|
||||
# Michael Bienia <geser@ubuntu.com>
|
||||
# Daniel Hahler <ubuntu@thequod.de>
|
||||
# Iain Lane <laney@ubuntu.com>
|
||||
# Jonathan Davies <jpds@ubuntu.com>
|
||||
@ -35,7 +35,7 @@ from optparse import OptionParser
|
||||
# ubuntu-dev-tools modules.
|
||||
import ubuntutools.lp.libsupport as lp_libsupport
|
||||
import ubuntutools.lp.udtexceptions as udtexceptions
|
||||
from ubuntutools.lp.lpapiwrapper import Launchpad, LpApiWrapper
|
||||
from ubuntutools.lp.lpapicache import Launchpad, LpApiWrapper, Distribution, PersonTeam
|
||||
# https_proxy fix
|
||||
import ubuntutools.common
|
||||
import ubuntutools.packages
|
||||
@ -95,7 +95,7 @@ def checkExistingReports(package):
|
||||
return False
|
||||
|
||||
# Fetch the package's bug list from Launchpad.
|
||||
pkg = LpApiWrapper.getUbuntuDistribution().getSourcePackage(name=package)
|
||||
pkg = Distribution('ubuntu').getSourcePackage(name=package)
|
||||
pkgBugList = pkg.searchTasks()
|
||||
|
||||
# Search bug list for other sync requests.
|
||||
@ -121,7 +121,7 @@ def checkExistingReports(package):
|
||||
def cur_version_component(sourcepkg, release):
|
||||
|
||||
try:
|
||||
src = LpApiWrapper.getUbuntuSourcePackage(sourcepkg, release)
|
||||
src = Distribution('ubuntu').getArchive().getSourcePackage(sourcepkg, release)
|
||||
return (src.getVersion(), src.getComponent())
|
||||
|
||||
except udtexceptions.PackageNotFoundException:
|
||||
@ -301,7 +301,7 @@ def post_bug(source_package, subscribe, status, bugtitle, bugtext):
|
||||
#newly created bugreports have one task
|
||||
task = bug.bug_tasks[0]
|
||||
# Only members of ubuntu-bugcontrol can set importance
|
||||
if LpApiWrapper.getMe().isLpTeamMember('ubuntu-bugcontrol'):
|
||||
if PersonTeam.getMe().isLpTeamMember('ubuntu-bugcontrol'):
|
||||
task.importance = 'Wishlist'
|
||||
task.status = status
|
||||
task.lp_save()
|
||||
@ -412,7 +412,7 @@ if __name__ == '__main__':
|
||||
sys.exit(1)
|
||||
|
||||
if len(args) not in (2, 3): # no release specified, assume development release
|
||||
release = LpApiWrapper.getUbuntuDistribution().getDevelopmentSeries().name
|
||||
release = Distribution('ubuntu').getDevelopmentSeries().name
|
||||
print >> sys.stderr, ("Source package / target release missing - assuming %s " %
|
||||
release)
|
||||
else:
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# lpapiwrapper.py - wrapper class around the LP API for use in the
|
||||
# ubuntu-dev-tools package
|
||||
# lpapicache.py - wrapper classes around the LP API implementing caching
|
||||
# for usage in the ubuntu-dev-tools package
|
||||
#
|
||||
# Copyright © 2009 Michael Bienia <geser@ubuntu.com>
|
||||
#
|
||||
@ -29,8 +29,6 @@ from launchpadlib.errors import HTTPError
|
||||
from launchpadlib.resource import Entry
|
||||
from udtexceptions import *
|
||||
|
||||
__all__ = ['LpApiWrapper']
|
||||
|
||||
class Launchpad(object):
|
||||
''' Singleton for LP API access. '''
|
||||
__lp = None
|
||||
@ -52,38 +50,13 @@ class Launchpad(object):
|
||||
return self
|
||||
Launchpad = Launchpad()
|
||||
|
||||
# Almost deprecated, better use the specific classes like Distribution
|
||||
# or PersonTeam directly
|
||||
class LpApiWrapper(object):
|
||||
'''
|
||||
Wrapper around some common used LP API functions used in
|
||||
ubuntu-dev-tools.
|
||||
'''
|
||||
_me = None
|
||||
|
||||
@classmethod
|
||||
def getMe(cls):
|
||||
'''
|
||||
Returns a PersonTeam object of the currently authenticated LP user.
|
||||
'''
|
||||
if not cls._me:
|
||||
cls._me = PersonTeam(Launchpad.me)
|
||||
return cls._me
|
||||
|
||||
@classmethod
|
||||
def getUbuntuDistribution(cls):
|
||||
'''
|
||||
Returns a Distibution object for Ubuntu.
|
||||
'''
|
||||
return Distribution('ubuntu')
|
||||
|
||||
@classmethod
|
||||
def getUbuntuSourcePackage(cls, name, series, pocket = 'Release'):
|
||||
'''
|
||||
Finds an Ubuntu source package on LP.
|
||||
|
||||
Returns a wrapped LP representation of the source package.
|
||||
If the package does not exist: raise PackageNotFoundException
|
||||
'''
|
||||
return cls.getUbuntuDistribution().getArchive().getSourcePackage(name, series, pocket)
|
||||
|
||||
@classmethod
|
||||
def canUploadPackage(cls, srcpkg, series = None):
|
||||
@ -97,14 +70,14 @@ class LpApiWrapper(object):
|
||||
assume 'universe' for component.
|
||||
'''
|
||||
component = 'universe'
|
||||
archive = cls.getUbuntuDistribution().getArchive()
|
||||
archive = Distribution('ubuntu').getArchive()
|
||||
|
||||
if isinstance(srcpkg, SourcePackage):
|
||||
package = srcpkg.getPackageName()
|
||||
component = srcpkg.getComponent()
|
||||
else:
|
||||
if not series:
|
||||
series = cls.getUbuntuDistribution().getDevelopmentSeries()
|
||||
series = Distribution('ubuntu').getDevelopmentSeries()
|
||||
try:
|
||||
srcpkg = archive.getSourcePackage(srcpkg, series)
|
||||
package = srcpkg.getPackageName()
|
||||
@ -112,7 +85,7 @@ class LpApiWrapper(object):
|
||||
except PackageNotFoundException:
|
||||
package = None
|
||||
|
||||
return cls.getMe().canUploadPackage(archive, package, component)
|
||||
return PersonTeam.getMe().canUploadPackage(archive, package, component)
|
||||
|
||||
# TODO: check if this is still needed after ArchiveReorg (or at all)
|
||||
@classmethod
|
||||
@ -123,9 +96,9 @@ class LpApiWrapper(object):
|
||||
if isinstance(package, SourcePackage):
|
||||
package = package.getPackageName()
|
||||
|
||||
archive = cls.getUbuntuDistribution().getArchive()
|
||||
archive = Distribution('ubuntu').getArchive()
|
||||
|
||||
return cls.getMe().canUploadPackage(archive, package, None)
|
||||
return PersonTeam.getMe().canUploadPackage(archive, package, None)
|
||||
|
||||
|
||||
class MetaWrapper(type):
|
||||
@ -429,6 +402,8 @@ class PersonTeam(BaseWrapper):
|
||||
'''
|
||||
resource_type = ('https://api.edge.launchpad.net/beta/#person', 'https://api.edge.launchpad.net/beta/#team')
|
||||
|
||||
_me = None # the PersonTeam object of the currently authenticated LP user
|
||||
|
||||
def __init__(self, *args):
|
||||
# Don't share _upload_{pkg,comp} between different PersonTeams
|
||||
if '_upload_pkg' not in self.__dict__:
|
||||
@ -454,6 +429,15 @@ class PersonTeam(BaseWrapper):
|
||||
cached = PersonTeam(Launchpad.people[person_or_team])
|
||||
return cached
|
||||
|
||||
@classmethod
|
||||
def getMe(cls):
|
||||
'''
|
||||
Returns a PersonTeam object of the currently authenticated LP user.
|
||||
'''
|
||||
if not cls._me:
|
||||
cls._me = PersonTeam(Launchpad.me)
|
||||
return cls._me
|
||||
|
||||
def isLpTeamMember(self, team):
|
||||
'''
|
||||
Checks if the user is a member of a certain team on Launchpad.
|
Loading…
x
Reference in New Issue
Block a user