* common.py: Removed print "Using cookie file" line.

* requestsync:
  - Using the Launchpad cookie file, validate that the user is a member
    the ubuntu-dev team on Launchpad. Thus, checking if the user needs
    sponsership or not (LP: #130648).
* doc/requestsync.1: Removed mention of -s flag. Obsoleted by the above.
This commit is contained in:
Jonathan Patrick Davies 2008-08-12 13:52:05 +01:00
parent 4a493b0c7a
commit 05c55bfbe2
4 changed files with 49 additions and 26 deletions

View File

@ -89,8 +89,6 @@ def prepareLaunchpadCookie():
launchpad_cookiefile = "%s/.lpcookie.txt" % os.environ.get('HOME')
print "Using cookie file at: %s." % launchpad_cookiefile
# Return the Launchpad cookie.
return launchpad_cookiefile

9
debian/changelog vendored
View File

@ -16,8 +16,13 @@ ubuntu-dev-tools (0.37ubuntu1) intrepid; urgency=low
to authenticate with Launchpad.
* debian/ubuntu-dev-tools.install: Added line to install common.py above to
the correct location.
* requestsync: Use the functions in the common.py file above to authenticate
with Launchpad.
* requestsync:
- Use the functions in the common.py file above to authenticate with
Launchpad.
- Using the Launchpad cookie file, validate that the user is a member of
the ubuntu-dev team on Launchpad. Thus, checking if the user needs
sponsership or not (LP: #130648).
* doc/requestsync.1: Removed mention of -s flag. Obsoleted by the above.
* debian/control: Changed XS-Python-Version to >= 2.5.
[ Siegfried-Angel Gevatter Pujals ]

View File

@ -29,11 +29,6 @@ Display a help message and exit.
Specifies that the package is a new package, and requestsync should not
attempt to look it up in Ubuntu since it will not exist.
.TP
.B \-s
Specifies that you require sponsorship.
You need this option if you are not a member of ubuntu-dev for universe or
multiverse, or ubuntu-core-dev for main or restricted.
.TP
.B \-k \fI<keyid>\fR
Specifies your GPG key.
Can also be set with the line `\fIexport GPGKEY=<keyid>\fR' in your shell's

View File

@ -8,6 +8,7 @@
# Michael Bienia <geser@ubuntu.com> (python-launchpad-bugs support)
# Daniel Hahler <ubuntu@thequod.de>
# Iain Lane <iain@orangesquash.org.uk>
# Jonathan Patrick Davies <jpds@ubuntu.com>
#
# ##################################################################
#
@ -24,17 +25,45 @@
#
# ##################################################################
import os, sys, urllib, subprocess, getopt
import getopt
import os
import re
import subprocess
import sys
import urllib
from debian_bundle.changelog import Version
# Set this to the path of your Launchpad cookie file, when using
# python-launchpad-bugs support (--lp).
# The following will be tried automatically, if unset (first match gets used):
# 1. ~/.lpcookie.txt
# 2. ~/.mozilla/*/*/cookies.sqlite
# 3. ~/.mozilla/*/*/cookies.txt
launchpad_cookiefile = None
# Use functions from ubuntu-dev-tools to create Launchpad cookie file.
sys.path.append('/usr/share/ubuntu-dev-tools/')
import common
launchpad_cookiefile = common.prepareLaunchpadCookie()
def checkNeedsSponsorship():
"""
Check that the user has the appropriate permissions by checking what
Launchpad returns while authenticating with their cookie.
If they are an indirect or direct member of the ~ubuntu-dev team on
Launchpad - sponsorship is not required.
The prepareLaunchpadCookie function above shall ensure that a cookie
file exists first.
"""
urlopener = common.setupLaunchpadUrlOpener(launchpad_cookiefile)
ubuntuDevLPPage = urlopener.open('https://launchpad.net/~ubuntu-dev').read()
if 'You are not a member of this team:' in ubuntuDevLPPage:
print "You are not a member (direct or indirect) of the ~ubuntu-dev " \
"team on Launchpad."
print "Your sync request shall require an approval by a member of " \
"either the ubuntu-main-sponsors or the ubuntu-universe-sponsors " \
"team,"
print "before it is processed by a member of the Ubuntu Archive admins."
return True # Sponsorship required.
else:
return False # Sponsorship not required.
def cur_version_component(sourcepkg, release):
'''Determine current package version in ubuntu.'''
@ -247,7 +276,6 @@ def post_bug(source_package, subscribe, status, bugtitle, bugtext):
Return True if successfully posted, otherwise False.'''
import glob, os.path
global launchpad_cookiefile
try:
import launchpadbugs.connector
@ -255,11 +283,7 @@ def post_bug(source_package, subscribe, status, bugtitle, bugtext):
print >> sys.stderr, 'Importing launchpadbugs failed. Is python-launchpad-bugs installed?'
return False
# Use functions from ubuntu-dev-tools to create Launchpad cookie file.
sys.path.append('/usr/share/ubuntu-dev-tools/')
import common
launchpad_cookiefile = common.prepareLaunchpadCookie()
print "Using cookie file at", launchpad_cookiefile
if source_package:
product = {'name': source_package, 'target': 'ubuntu'}
@ -311,7 +335,7 @@ def edit_report(subject, body, changes_required=False):
program exits.
Returns (new_subject, new_body).
"""
import re, string
import string
report = "Summary (one line):\n%s\n\nDescription:\n%s" % (subject, body)
@ -361,16 +385,17 @@ if __name__ == '__main__':
need_interaction = False
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], 'hnsk:', ('lp'))
opts, args = getopt.gnu_getopt(sys.argv[1:], 'hnk:', ('lp'))
except getopt.GetoptError:
usage()
for o, a in opts:
if o == '-h': usage()
if o == '-n': newsource = True
if o == '-s': sponsorship = True
if o == '-k': keyid = a
if o == '--lp': use_lp_bugs = True
sponsorship = checkNeedsSponsorship()
if len(args) not in (2, 3):
usage()