mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
* common.py: New function: isLPTeamMember() - checks if the user is a member of
the Launchpad team using cookies for authentication. * requestsync: Adapt team checking with the function above. * buildd: Adapt privilege checking code to the new function above.
This commit is contained in:
parent
839c167927
commit
3c25fca142
14
buildd
14
buildd
@ -120,6 +120,20 @@ for m in re.finditer('"/ubuntu/\+source/%s/%s(/\+build/\d+)"[^\n]+\n\s*(\w+).*?<
|
||||
if op == 'status':
|
||||
sys.exit(0)
|
||||
|
||||
# Leaving operations may only be done by Ubuntu developers (retry) or buildd
|
||||
# admins (rescore). Check if the proper permissions are in place.
|
||||
if op == "rescore": teamNeeded = "launchpad-buildd-admins"
|
||||
if op == "retry": teamNeeded = "ubuntu-dev"
|
||||
|
||||
necessaryPrivs = common.isLPTeamMember(teamNeeded)
|
||||
|
||||
if not necessaryPrivs:
|
||||
print >> sys.stderr, "You cannot perform the %s operation as you are not " \
|
||||
"a member of the '%s' team on Launchpad." % (op, teamNeeded)
|
||||
print "If this is incorrect, please log in to Launchpad using Firefox, " \
|
||||
"delete the ~/.lpcookie.txt file and rerun this script."
|
||||
sys.exit(1)
|
||||
|
||||
for build, (arch, status) in buildstats.iteritems():
|
||||
if oneArch and not options.architecture == arch:
|
||||
# Skip this architecture.
|
||||
|
31
common.py
31
common.py
@ -202,3 +202,34 @@ def setupLaunchpadUrlOpener(cookie):
|
||||
urlopener.add_handler(urllib2.HTTPCookieProcessor(cj))
|
||||
|
||||
return urlopener
|
||||
|
||||
def isLPTeamMember(team):
|
||||
""" Checks if the user is a member of a certain team on Launchpad.
|
||||
|
||||
We do this by opening the team page on Launchpad and checking if the
|
||||
text "You are not a member of this team" is present using the
|
||||
user's cookie file for authentication.
|
||||
|
||||
If the user is a member of the team: return True.
|
||||
If the user is not a member of the team: return False.
|
||||
"""
|
||||
|
||||
# TODO: Check if launchpadlib may be a better way of doing this.
|
||||
|
||||
# Prepare cookie.
|
||||
cookieFile = prepareLaunchpadCookie()
|
||||
# Prepare URL opener.
|
||||
urlopener = setupLaunchpadUrlOpener(cookieFile)
|
||||
|
||||
# Try to open the Launchpad team page:
|
||||
try:
|
||||
lpTeamPage = urlopener.open("https://launchpad.net/~%s" % team).read()
|
||||
except urllib2.HTTPError, error:
|
||||
print >> sys.stderr, "Unable to connect to Launchpad. Received a %s." % error.code
|
||||
sys.exit(1)
|
||||
|
||||
# Check if text is present in page.
|
||||
if ("You are not a member of this team") in lpTeamPage:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
9
debian/changelog
vendored
9
debian/changelog
vendored
@ -4,8 +4,13 @@ ubuntu-dev-tools (0.43ubuntu1) intrepid; urgency=low
|
||||
* common.py:
|
||||
- If loading a cookie file raises an exception exit.
|
||||
- Improve cookie file writing.
|
||||
* requestsync: Return an error when the script is unable to connect to
|
||||
packages.debian.org (LP: #261916).
|
||||
- New function: isLPTeamMember() - checks if the user is a member of the
|
||||
Launchpad team using cookies for authentication.
|
||||
* requestsync:
|
||||
- Return an error when the script is unable to connect to
|
||||
packages.debian.org (LP: #261916).
|
||||
- Adapt team checking with the function above.
|
||||
* buildd: Adapt privilege checking code to the new function above.
|
||||
|
||||
[ Ryan Kavanagh ]
|
||||
* dgetlp.1: New manpage
|
||||
|
20
requestsync
20
requestsync
@ -62,20 +62,11 @@ def checkNeedsSponsorship(component):
|
||||
else:
|
||||
team = "ubuntu-dev"
|
||||
sponsor = "ubuntu-universe-sponsors"
|
||||
|
||||
# Try and open up Launchpad.
|
||||
try: teamLPPage = urlopener.open('https://launchpad.net/~%s' % team).read()
|
||||
except urllib2.HTTPError:
|
||||
print >> sys.stderr, "Unable to connect to Launchpad."
|
||||
sys.exit(1)
|
||||
|
||||
# Check if they are a member of the team.
|
||||
if "You are an indirect member of this team:" in teamLPPage or \
|
||||
"You are a member of this team." in teamLPPage:
|
||||
return False # Sponsorship not required.
|
||||
|
||||
# Check if they are not.
|
||||
if "You are not a member of this team" in teamLPPage:
|
||||
# Check if they are a member of the team.
|
||||
teamMember = common.isLPTeamMember(team)
|
||||
|
||||
if not teamMember:
|
||||
print "You are not a member (direct or indirect) of the '%s' " \
|
||||
"team on Launchpad." % team
|
||||
print "Your sync request shall require an approval by a member of " \
|
||||
@ -87,6 +78,9 @@ def checkNeedsSponsorship(component):
|
||||
raw_input_exit_on_ctrlc() # Abort if necessary.
|
||||
return True # Sponsorship required.
|
||||
|
||||
# Is a team member, no sponsorship required.
|
||||
return False
|
||||
|
||||
def cur_version_component(sourcepkg, release):
|
||||
'''Determine current package version in ubuntu.'''
|
||||
madison = subprocess.Popen(['rmadison', '-u', 'ubuntu', '-a', 'source', \
|
||||
|
Loading…
x
Reference in New Issue
Block a user