Whitespace and style cleanups

This commit is contained in:
Stefano Rivera 2010-12-23 00:01:39 +02:00
parent 3f694feb94
commit 9fa9f3eb96
5 changed files with 192 additions and 137 deletions

View File

@ -43,43 +43,46 @@ from ubuntutools.requestsync.common import (edit_report, getDebianChangelog,
if __name__ == '__main__': if __name__ == '__main__':
# Our usage options. # Our usage options.
usage = 'Usage: %prog [options] ' \ usage = ('Usage: %prog [options] '
'<source package> [<target release> [base version]]' '<source package> [<target release> [base version]]')
optParser = OptionParser(usage) p = OptionParser(usage)
optParser.add_option('-d', type='string', p.add_option('-d', type='string',
dest='dist', default='unstable', dest='dist', default='unstable',
help='Debian distribution to sync from.') help='Debian distribution to sync from.')
optParser.add_option('-k', type='string', p.add_option('-k', type='string',
dest='keyid', default=None, dest='keyid', default=None,
help='GnuPG key ID to use for signing report (only used when emailing the sync request).') help='GnuPG key ID to use for signing report '
optParser.add_option('-n', action='store_true', '(only used when emailing the sync request).')
p.add_option('-n', action='store_true',
dest='newpkg', default=False, dest='newpkg', default=False,
help='Whether package to sync is a new package in Ubuntu.') help='Whether package to sync is a new package in Ubuntu.')
optParser.add_option('--lp', action='store_true', p.add_option('--lp', action='store_true',
dest='lpapi', default=False, dest='lpapi', default=False,
help='Specify whether to use the LP API for filing the sync request (recommended).') help='Specify whether to use the LP API for filing '
optParser.add_option('-l', '--lpinstance', type='string', metavar='INSTANCE', 'the sync request (recommended).')
p.add_option('-l', '--lpinstance', metavar='INSTANCE',
dest='lpinstance', default=None, dest='lpinstance', default=None,
help='Launchpad instance to connect to (default: production).') help='Launchpad instance to connect to (default: production).')
optParser.add_option('-s', action='store_true', p.add_option('-s', action='store_true',
dest='sponsorship', default=False, dest='sponsorship', default=False,
help='Force sponsorship') help='Force sponsorship')
optParser.add_option('-C', action='store_true', p.add_option('-C', action='store_true',
dest='missing_changelog_ok', default=False, dest='missing_changelog_ok', default=False,
help='Allow changelog to be manually filled in when missing') help='Allow changelog to be manually filled in when missing')
optParser.add_option('-e', action='store_true', p.add_option('-e', action='store_true',
dest='ffe', default=False, dest='ffe', default=False,
help='Use this after FeatureFreeze for non-bug fix syncs, changes ' \ help='Use this after FeatureFreeze for non-bug fix syncs, '
'default subscription to the appropriate release team.') 'changes default subscription to the appropriate '
optParser.add_option('--no-conf', action='store_true', 'release team.')
p.add_option('--no-conf', action='store_true',
dest='no_conf', default=False, dest='no_conf', default=False,
help="Don't read config files or environment variables") help="Don't read config files or environment variables")
(options, args) = optParser.parse_args() (options, args) = p.parse_args()
if not len(args): if not len(args):
optParser.print_help() p.print_help()
sys.exit(1) sys.exit(1)
config = UDTConfig(options.no_conf) config = UDTConfig(options.no_conf)
@ -92,11 +95,14 @@ if __name__ == '__main__':
default='fiordland.ubuntu.com', default='fiordland.ubuntu.com',
compat_keys=['UBUSMTP', 'DEBSMTP']) compat_keys=['UBUSMTP', 'DEBSMTP'])
mailserver_port = config.get_value('SMTP_PORT', default=25, mailserver_port = config.get_value('SMTP_PORT', default=25,
compat_keys=['UBUSMTP_PORT', 'DEBSMTP_PORT']) compat_keys=['UBUSMTP_PORT',
'DEBSMTP_PORT'])
mailserver_user = config.get_value('SMTP_USER', mailserver_user = config.get_value('SMTP_USER',
compat_keys=['UBUSMTP_USER', 'DEBSMTP_USER']) compat_keys=['UBUSMTP_USER',
'DEBSMTP_USER'])
mailserver_pass = config.get_value('SMTP_PASS', mailserver_pass = config.get_value('SMTP_PASS',
compat_keys=['UBUSMTP_PASS', 'DEBSMTP_PASS']) compat_keys=['UBUSMTP_PASS',
'DEBSMTP_PASS'])
# import the needed requestsync module # import the needed requestsync module
if options.lpapi: if options.lpapi:
@ -105,7 +111,8 @@ if __name__ == '__main__':
getUbuntuSrcPkg, getUbuntuSrcPkg,
needSponsorship, postBug) needSponsorship, postBug)
from ubuntutools.lp.lpapicache import Distribution, Launchpad from ubuntutools.lp.lpapicache import Distribution, Launchpad
# See if we have LP credentials and exit if we don't - cannot continue in this case # See if we have LP credentials and exit if we don't -
# cannot continue in this case
try: try:
Launchpad.login(service=options.lpinstance) Launchpad.login(service=options.lpinstance)
@ -144,7 +151,7 @@ if __name__ == '__main__':
force_base_version = Version(args[2]) force_base_version = Version(args[2])
else: else:
print >> sys.stderr, 'E: Too many arguments.' print >> sys.stderr, 'E: Too many arguments.'
optParser.print_help() p.print_help()
sys.exit(1) sys.exit(1)
# Get the current Ubuntu source package # Get the current Ubuntu source package
@ -158,9 +165,11 @@ if __name__ == '__main__':
ubuntu_version = Version('~') ubuntu_version = Version('~')
ubuntu_component = 'universe' # let's assume universe ubuntu_component = 'universe' # let's assume universe
if not newsource: if not newsource:
print "'%s' doesn't exist in 'Ubuntu %s'.\nDo you want to sync a new package?" % \ print ("'%s' doesn't exist in 'Ubuntu %s'.\n"
(srcpkg, release) "Do you want to sync a new package?"
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ') % (srcpkg, release))
raw_input_exit_on_ctrlc('Press [Enter] to continue '
'or [Ctrl-C] to abort. ')
newsource = True newsource = True
# Get the requested Debian source package # Get the requested Debian source package
@ -177,7 +186,8 @@ if __name__ == '__main__':
# try rmadison # try rmadison
import ubuntutools.requestsync.mail import ubuntutools.requestsync.mail
try: try:
debian_srcpkg = ubuntutools.requestsync.mail.getDebianSrcPkg(srcpkg, distro) debian_srcpkg = ubuntutools.requestsync.mail.getDebianSrcPkg(
srcpkg, distro)
debian_version = Version(debian_srcpkg.getVersion()) debian_version = Version(debian_srcpkg.getVersion())
debian_component = debian_srcpkg.getComponent() debian_component = debian_srcpkg.getComponent()
except udtexceptions.PackageNotFoundException, e: except udtexceptions.PackageNotFoundException, e:
@ -185,12 +195,14 @@ if __name__ == '__main__':
sys.exit(1) sys.exit(1)
if ubuntu_version == debian_version: if ubuntu_version == debian_version:
print >> sys.stderr, \ print >> sys.stderr, ('E: The versions in Debian and Ubuntu are the '
'E: The versions in Debian and Ubuntu are the same already (%s). Aborting.' % ubuntu_version 'same already (%s). Aborting.'
% ubuntu_version)
sys.exit(1) sys.exit(1)
if ubuntu_version > debian_version: if ubuntu_version > debian_version:
print >> sys.stderr, \ print >> sys.stderr, ('E: The version in Ubuntu (%s) is newer than '
'E: The version in Ubuntu (%s) is newer than the version in Debian (%s). Aborting.' % (ubuntu_version, debian_version) 'the version in Debian (%s). Aborting.'
% (ubuntu_version, debian_version))
sys.exit(1) sys.exit(1)
# -s flag not specified - check if we do need sponsorship # -s flag not specified - check if we do need sponsorship
@ -202,8 +214,9 @@ if __name__ == '__main__':
checkExistingReports(srcpkg) checkExistingReports(srcpkg)
# Generate bug report # Generate bug report
pkg_to_sync = '%s %s (%s) from Debian %s (%s)' % \ pkg_to_sync = ('%s %s (%s) from Debian %s (%s)'
(srcpkg, debian_version, ubuntu_component, distro, debian_component) % (srcpkg, debian_version, ubuntu_component,
distro, debian_component))
title = "Sync %s" % pkg_to_sync title = "Sync %s" % pkg_to_sync
if ffe: if ffe:
title = "FFe: " + title title = "FFe: " + title
@ -212,43 +225,50 @@ if __name__ == '__main__':
if 'ubuntu' in str(ubuntu_version): if 'ubuntu' in str(ubuntu_version):
need_interaction = True need_interaction = True
print 'Changes have been made to the package in Ubuntu.\n' \ print ('Changes have been made to the package in Ubuntu.\n'
'Please edit the report and give an explanation.\n' \ 'Please edit the report and give an explanation.\n'
'Not saving the report file will abort the request.' 'Not saving the report file will abort the request.')
report += 'Explanation of the Ubuntu delta and why it can be dropped:\n' \ report += ('Explanation of the Ubuntu delta and why it can be '
'>>> ENTER_EXPLANATION_HERE <<<\n\n' 'dropped:\n>>> ENTER_EXPLANATION_HERE <<<\n\n')
if ffe: if ffe:
need_interaction = True need_interaction = True
print 'To approve FeatureFreeze exception, you need to state\n' \ print ('To approve FeatureFreeze exception, you need to state\n'
'the reason why you feel it is necessary.\n' \ 'the reason why you feel it is necessary.\n'
'Not saving the report file will abort the request.' 'Not saving the report file will abort the request.')
report += 'Explanation of FeatureFreeze exception:\n' \ report += ('Explanation of FeatureFreeze exception:\n'
'>>> ENTER_EXPLANATION_HERE <<<\n\n' '>>> ENTER_EXPLANATION_HERE <<<\n\n')
if need_interaction: if need_interaction:
raw_input_exit_on_ctrlc('Press [Enter] to continue. Press [Ctrl-C] to abort now. ') raw_input_exit_on_ctrlc('Press [Enter] to continue.'
'Press [Ctrl-C] to abort now. ')
base_version = force_base_version or ubuntu_version base_version = force_base_version or ubuntu_version
if newsource: if newsource:
report += 'All changelog entries:\n\n' report += 'All changelog entries:\n\n'
else: else:
report += 'Changelog entries since current %s version %s:\n\n' % (release, ubuntu_version) report += ('Changelog entries since current %s version %s:\n\n'
% (release, ubuntu_version))
changelog = getDebianChangelog(debian_srcpkg, base_version) changelog = getDebianChangelog(debian_srcpkg, base_version)
if not changelog: if not changelog:
if not options.missing_changelog_ok: if not options.missing_changelog_ok:
print >> sys.stderr, "E: Did not retrieve any changelog entries. Do you need to specify '-C'? Was the package recently uploaded? (check http://packages.debian.org/changelogs/)" print >> sys.stderr, ("E: Did not retrieve any changelog entries. "
"Do you need to specify '-C'? "
"Was the package recently uploaded? (check "
"http://packages.debian.org/changelogs/)")
sys.exit(1) sys.exit(1)
else: else:
need_interaction = True need_interaction = True
changelog = "XXX FIXME: add changelog here XXX" changelog = "XXX FIXME: add changelog here XXX"
report += changelog report += changelog
(title, report) = edit_report(title, report, changes_required = need_interaction) (title, report) = edit_report(title, report,
changes_required=need_interaction)
if 'XXX FIXME' in report: if 'XXX FIXME' in report:
print >> sys.stderr, "E: changelog boilerplate found in report, please manually add changelog when using '-C'" print >> sys.stderr, ("E: changelog boilerplate found in report, "
"please manually add changelog when using '-C'")
sys.exit(1) sys.exit(1)
# bug status and bug subscriber # bug status and bug subscriber

View File

@ -27,7 +27,8 @@ import sys
from optparse import OptionGroup from optparse import OptionGroup
from optparse import OptionParser from optparse import OptionParser
from ubuntutools.lp.udtexceptions import (SeriesNotFoundException, from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
PackageNotFoundException, PocketDoesNotExistError,) PackageNotFoundException,
PocketDoesNotExistError,)
from ubuntutools.lp.lpapicache import Distribution, PersonTeam from ubuntutools.lp.lpapicache import Distribution, PersonTeam
from ubuntutools.misc import splitReleasePocket from ubuntutools.misc import splitReleasePocket
@ -53,26 +54,28 @@ retryRescoreOptions.add_option("-a", "--arch", type = "string",
"%s." % ", ".join(valid_archs)) "%s." % ", ".join(valid_archs))
# Batch processing options # Batch processing options
batch_options = OptionGroup( batch_options = OptionGroup(optParser, "Batch processing",
optParser, "Batch processing",
"These options and parameter ordering is only available in --batch mode.\n" "These options and parameter ordering is only available in --batch mode.\n"
"Usage: ubuntu-build --batch [options] <package>...") "Usage: ubuntu-build --batch [options] <package>...")
batch_options.add_option( batch_options.add_option('--batch',
'--batch', action = 'store_true', dest = 'batch', default = False, action='store_true', dest='batch', default=False,
help='Enable batch mode') help='Enable batch mode')
batch_options.add_option( batch_options.add_option('--series',
'--series', action = 'store', dest = 'series', type = 'string', action='store', dest='series', type='string',
help = 'Selects the Ubuntu series to operate on (default: current development series)') help='Selects the Ubuntu series to operate on '
batch_options.add_option( '(default: current development series)')
'--retry', action = 'store_true', dest = 'retry', default = False, batch_options.add_option('--retry',
action='store_true', dest='retry', default=False,
help='Retry builds (give-back).') help='Retry builds (give-back).')
batch_options.add_option( batch_options.add_option('--rescore',
'--rescore', action = 'store', dest = 'priority', type = 'int', action='store', dest='priority', type='int',
help='Rescore builds to <priority>.') help='Rescore builds to <priority>.')
batch_options.add_option( batch_options.add_option('--arch2',
'--arch2', action = 'append', dest = 'architecture', type = 'string', action='append', dest='architecture', type='string',
help = "Affect only 'architecture' (can be used several times). " help="Affect only 'architecture' "
"Valid architectures are: %s." % ', '.join(valid_archs)) "(can be used several times). "
"Valid architectures are: %s."
% ', '.join(valid_archs))
# Add the retry options to the main group. # Add the retry options to the main group.
optParser.add_option_group(retryRescoreOptions) optParser.add_option_group(retryRescoreOptions)
@ -104,11 +107,12 @@ if not options.batch:
print >> sys.stderr, "Invalid operation: %s." % op print >> sys.stderr, "Invalid operation: %s." % op
sys.exit(1) sys.exit(1)
# If the user has specified an architecture to build, we only wish to rebuild it # If the user has specified an architecture to build, we only wish to
# and nothing else. # rebuild it and nothing else.
if options.architecture: if options.architecture:
if options.architecture[0] not in valid_archs: if options.architecture[0] not in valid_archs:
print >> sys.stderr, "Invalid architecture specified: %s." % options.architecture[0] print >> sys.stderr, ("Invalid architecture specified: %s."
% options.architecture[0])
sys.exit(1) sys.exit(1)
else: else:
oneArch = True oneArch = True
@ -142,21 +146,26 @@ if not options.batch:
version = sources.getVersion() version = sources.getVersion()
component = sources.getComponent() component = sources.getComponent()
# Operations that are remaining may only be done by Ubuntu developers (retry) # Operations that are remaining may only be done by Ubuntu developers
# or buildd admins (rescore). Check if the proper permissions are in place. # (retry) or buildd admins (rescore). Check if the proper permissions are
# in place.
me = PersonTeam.me me = PersonTeam.me
if op == "rescore": necessaryPrivs = me.isLpTeamMember('launchpad-buildd-admins') if op == "rescore":
if op == "retry": necessaryPrivs = me.canUploadPackage( necessaryPrivs = me.isLpTeamMember('launchpad-buildd-admins')
ubuntu_archive, distroseries, sources.getPackageName(), sources.getComponent()) if op == "retry":
necessaryPrivs = me.canUploadPackage(ubuntu_archive, distroseries,
sources.getPackageName(),
sources.getComponent())
if op in ('rescore', 'retry') and not necessaryPrivs: if op in ('rescore', 'retry') and not necessaryPrivs:
print >> sys.stderr, "You cannot perform the %s operation on a %s package " \ print >> sys.stderr, ("You cannot perform the %s operation on a %s "
"as you do not have the permissions to do this action." % (op, component) "package as you do not have the permissions to "
"do this action." % (op, component))
sys.exit(1) sys.exit(1)
# Output details. # Output details.
print "The source version for '%s' in %s (%s) is at %s." % (package, print ("The source version for '%s' in %s (%s) is at %s."
release.capitalize(), component, version) % (package, release.capitalize(), component, version))
print "Current build status for this package:" print "Current build status for this package:"
@ -188,8 +197,8 @@ if not options.batch:
# We are done # We are done
if done: sys.exit(0) if done: sys.exit(0)
print "No builds for '%s' found in the %s release - it may have been " \ print ("No builds for '%s' found in the %s release - it may have been "
"built in a former release." % (package, release.capitalize()) "built in a former release." % (package, release.capitalize()))
sys.exit(0) sys.exit(0)
# Batch mode # Batch mode
@ -219,9 +228,12 @@ except SeriesNotFoundException, e:
me = PersonTeam.me me = PersonTeam.me
# Check permisions (part 1): Rescoring can only be done by buildd admins # Check permisions (part 1): Rescoring can only be done by buildd admins
can_rescore = options.priority and me.isLpTeamMember('launchpad-buildd-admins') or False can_rescore = ((options.priority
and me.isLpTeamMember('launchpad-buildd-admins'))
or False)
if options.priority and not can_rescore: if options.priority and not can_rescore:
print >> sys.stderr, "You don't have the permissions to rescore builds. Ignoring your rescore request." print >> sys.stderr, ("You don't have the permissions to rescore builds. "
"Ignoring your rescore request.")
for pkg in args: for pkg in args:
try: try:
@ -230,10 +242,16 @@ for pkg in args:
print e print e
continue continue
# Check permissions (part 2): check upload permissions for the source package # Check permissions (part 2): check upload permissions for the source
can_retry = options.retry and me.canUploadPackage(ubuntu_archive, distroseries, pkg.getPackageName(), pkg.getComponent()) # package
can_retry = options.retry and me.canUploadPackage(ubuntu_archive,
distroseries,
pkg.getPackageName(),
pkg.getComponent())
if options.retry and not can_retry: if options.retry and not can_retry:
print >> sys.stderr, "You don't have the permissions to retry the build of '%s'. Ignoring your request." % pkg.getPackageName() print >> sys.stderr, ("You don't have the permissions to retry the "
"build of '%s'. Ignoring your request."
% pkg.getPackageName())
print "The source version for '%s' in '%s' (%s) is: %s" % ( print "The source version for '%s' in '%s' (%s) is: %s" % (
pkg.getPackageName(), release, pocket, pkg.getVersion()) pkg.getPackageName(), release, pocket, pkg.getVersion())

View File

@ -54,11 +54,13 @@ def getDebianChangelog(srcpkg, version):
# Get the debian changelog file from packages.debian.org # Get the debian changelog file from packages.debian.org
try: try:
changelog = urllib2.urlopen( changelog = urllib2.urlopen('http://packages.debian.org/changelogs/pool'
'http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog.txt' % \ '/%s/%s/%s/%s_%s/changelog.txt'
(component, subdir, pkgname, pkgname, pkgversion)) % (component, subdir, pkgname, pkgname,
pkgversion))
except urllib2.HTTPError, error: except urllib2.HTTPError, error:
print >> sys.stderr, 'Unable to connect to packages.debian.org: %s' % error print >> sys.stderr, ('Unable to connect to packages.debian.org: %s'
% error)
return None return None
new_entries = '' new_entries = ''
@ -88,7 +90,8 @@ def edit_report(subject, body, changes_required = False):
if not changes_required: if not changes_required:
print 'Currently the report looks as follows:\n%s' % report print 'Currently the report looks as follows:\n%s' % report
while True: while True:
val = raw_input_exit_on_ctrlc('Do you want to edit the report [y/N]? ') val = raw_input_exit_on_ctrlc('Do you want to edit the report '
'[y/N]? ')
if val.lower() in ('y', 'yes'): if val.lower() in ('y', 'yes'):
break break
elif val.lower() in ('n', 'no', ''): elif val.lower() in ('n', 'no', ''):
@ -108,15 +111,17 @@ def edit_report(subject, body, changes_required = False):
try: try:
subprocess.check_call(['sensible-editor', report_file.name]) subprocess.check_call(['sensible-editor', report_file.name])
except subprocess.CalledProcessError, e: except subprocess.CalledProcessError, e:
print >> sys.stderr, 'Error calling sensible-editor: %s\nAborting.' % e print >> sys.stderr, ('Error calling sensible-editor: %s\n'
'Aborting.' % e)
sys.exit(1) sys.exit(1)
# Check if the tempfile has been changed # Check if the tempfile has been changed
if changes_required: if changes_required:
if mtime_before == os.stat(report_file.name).st_mtime: if mtime_before == os.stat(report_file.name).st_mtime:
print 'The report has not been changed, but you have to explain why ' \ print ('The report has not been changed, but you have to '
'the Ubuntu changes can be dropped.' 'explain why the Ubuntu changes can be dropped.')
raw_input_exit_on_ctrlc('Press [Enter] to retry or [Control-C] to abort. ') raw_input_exit_on_ctrlc('Press [Enter] to retry or '
'[Control-C] to abort. ')
else: else:
changes_required = False changes_required = False
@ -127,6 +132,7 @@ def edit_report(subject, body, changes_required = False):
# Undecorate report again # Undecorate report again
(subject, body) = report.split("\nDescription:\n", 1) (subject, body) = report.split("\nDescription:\n", 1)
# Remove prefix and whitespace from subject # Remove prefix and whitespace from subject
subject = re.sub('^Summary \(one line\):\s*', '', subject, 1).strip() subject = re.sub('^Summary \(one line\):\s*', '', subject,
1).strip()
return (subject, body) return (subject, body)

View File

@ -21,7 +21,8 @@
# of the GNU General Public License license. # of the GNU General Public License license.
from ubuntutools.requestsync.common import raw_input_exit_on_ctrlc from ubuntutools.requestsync.common import raw_input_exit_on_ctrlc
from ubuntutools.lp.lpapicache import Launchpad, Distribution, PersonTeam, DistributionSourcePackage from ubuntutools.lp.lpapicache import (Launchpad, Distribution, PersonTeam,
DistributionSourcePackage)
from ubuntutools.lp.libsupport import translate_api_web from ubuntutools.lp.libsupport import translate_api_web
def getDebianSrcPkg(name, release): def getDebianSrcPkg(name, release):
@ -51,7 +52,8 @@ def needSponsorship(name, component, release):
archive = Distribution('ubuntu').getArchive() archive = Distribution('ubuntu').getArchive()
distroseries = Distribution('ubuntu').getSeries(release) distroseries = Distribution('ubuntu').getSeries(release)
need_sponsor = not PersonTeam.me.canUploadPackage(archive, distroseries, name, component) need_sponsor = not PersonTeam.me.canUploadPackage(archive, distroseries,
name, component)
if need_sponsor: if need_sponsor:
print '''You are not able to upload this package directly to Ubuntu. print '''You are not able to upload this package directly to Ubuntu.
Your sync request shall require an approval by a member of the appropriate Your sync request shall require an approval by a member of the appropriate
@ -77,18 +79,22 @@ def checkExistingReports(srcpkg):
for bug in pkgBugList: for bug in pkgBugList:
# check for Sync or sync and the package name # check for Sync or sync and the package name
if not bug.is_complete and 'ync %s' % srcpkg in bug.title: if not bug.is_complete and 'ync %s' % srcpkg in bug.title:
print 'The following bug could be a possible duplicate sync bug on Launchpad:' print ('The following bug could be a possible duplicate sync bug '
print ' * %s (%s)' % \ 'on Launchpad:\n'
(bug.title, translate_api_web(bug.self_link)) ' * %s (%s)\n'
print 'Please check the above URL to verify this before continuing.' 'Please check the above URL to verify this before '
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ') 'continuing.'
% (bug.title, translate_api_web(bug.self_link)))
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] '
'to abort. ')
def postBug(srcpkg, subscribe, status, bugtitle, bugtext): def postBug(srcpkg, subscribe, status, bugtitle, bugtext):
''' '''
Use the LP API to file the sync request. Use the LP API to file the sync request.
''' '''
print 'The final report is:\nSummary: %s\nDescription:\n%s\n' % (bugtitle, bugtext) print ('The final report is:\nSummary: %s\nDescription:\n%s\n'
% (bugtitle, bugtext))
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ') raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ')
if srcpkg: if srcpkg:
@ -99,7 +105,8 @@ def postBug(srcpkg, subscribe, status, bugtitle, bugtext):
bug_target = Distribution('ubuntu') bug_target = Distribution('ubuntu')
# create bug # create bug
bug = Launchpad.bugs.createBug(title = bugtitle, description = bugtext, target = bug_target()) bug = Launchpad.bugs.createBug(title=bugtitle, description=bugtext,
target=bug_target())
# newly created bugreports have only one task # newly created bugreports have only one task
task = bug.bug_tasks[0] task = bug.bug_tasks[0]
@ -111,5 +118,5 @@ def postBug(srcpkg, subscribe, status, bugtitle, bugtext):
bug.subscribe(person = PersonTeam(subscribe)()) bug.subscribe(person = PersonTeam(subscribe)())
print 'Sync request filed as bug #%i: %s' % (bug.id, print ('Sync request filed as bug #%i: %s'
translate_api_web(bug.self_link)) % (bug.id, translate_api_web(bug.self_link)))

View File

@ -64,8 +64,8 @@ def rmadison(distro, package, release):
} }
release = releasenames.get(release, release) release = releasenames.get(release, release)
rmadison_cmd = subprocess.Popen( rmadison_cmd = subprocess.Popen(['rmadison', '-u', distro, '-a', 'source',
['rmadison', '-u', distro, '-a', 'source', '-s', release, package], '-s', release, package],
stdout=subprocess.PIPE) stdout=subprocess.PIPE)
rmadison_out = rmadison_cmd.communicate()[0] rmadison_out = rmadison_cmd.communicate()[0]
@ -87,9 +87,9 @@ def rmadison(distro, package, release):
def getSrcPkg(distro, name, release): def getSrcPkg(distro, name, release):
out = rmadison(distro, name, release) out = rmadison(distro, name, release)
if not out: if not out:
raise PackageNotFoundException( raise PackageNotFoundException("'%s' doesn't appear to exist "
"'%s' doesn't appear to exist in %s '%s'" % \ "in %s '%s'"
(name, distro.capitalize(), release)) % (name, distro.capitalize(), release))
version = out[1] version = out[1]
component = 'main' component = 'main'
@ -112,8 +112,9 @@ def needSponsorship(name, component, release):
''' '''
while True: while True:
print "Do you have upload permissions for the '%s' component " \ print ("Do you have upload permissions for the '%s' component "
"or the package '%s' in Ubuntu %s?" % (component, name, release) "or the package '%s' in Ubuntu %s?"
% (component, name, release))
val = raw_input_exit_on_ctrlc("If in doubt answer 'n'. [y/N]? ") val = raw_input_exit_on_ctrlc("If in doubt answer 'n'. [y/N]? ")
if val.lower() in ('y', 'yes'): if val.lower() in ('y', 'yes'):
return False return False
@ -126,8 +127,9 @@ def checkExistingReports(srcpkg):
''' '''
Point the user to the URL to manually check for duplicate bug reports. Point the user to the URL to manually check for duplicate bug reports.
''' '''
print 'Please check on https://bugs.launchpad.net/ubuntu/+source/%s/+bugs\n' \ print ('Please check on '
'for duplicate sync requests before continuing.' % srcpkg 'https://bugs.launchpad.net/ubuntu/+source/%s/+bugs\n'
'for duplicate sync requests before continuing.' % srcpkg)
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ') raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ')
def mailBug(srcpkg, subscribe, status, bugtitle, bugtext, lpinstance, keyid, def mailBug(srcpkg, subscribe, status, bugtitle, bugtext, lpinstance, keyid,
@ -170,7 +172,8 @@ def mailBug(srcpkg, subscribe, status, bugtitle, bugtext, lpinstance, keyid,
gpg_command.extend(('-u', keyid)) gpg_command.extend(('-u', keyid))
# sign the mail body # sign the mail body
gpg = subprocess.Popen(gpg_command, stdin = subprocess.PIPE, stdout = subprocess.PIPE) gpg = subprocess.Popen(gpg_command, stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
signed_report = gpg.communicate(mailbody.encode('utf-8'))[0].decode('utf-8') signed_report = gpg.communicate(mailbody.encode('utf-8'))[0].decode('utf-8')
assert gpg.returncode == 0 assert gpg.returncode == 0
@ -199,7 +202,8 @@ Content-Type: text/plain; charset=UTF-8
try: try:
s.login(mailserver_user, mailserver_pass) s.login(mailserver_user, mailserver_pass)
except smtplib.SMTPAuthenticationError: except smtplib.SMTPAuthenticationError:
print >> sys.stderr, 'E: Error authenticating to the server: invalid username and password.' print >> sys.stderr, ('E: Error authenticating to the server: '
'invalid username and password.')
s.quit() s.quit()
return return
except: except: