From 9fa9f3eb960fba8c80842b7de62dd89aaf7655ef Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Thu, 23 Dec 2010 00:01:39 +0200 Subject: [PATCH] Whitespace and style cleanups --- requestsync | 150 +++++++++++++++++------------- ubuntu-build | 94 +++++++++++-------- ubuntutools/requestsync/common.py | 26 ++++-- ubuntutools/requestsync/lp.py | 29 +++--- ubuntutools/requestsync/mail.py | 30 +++--- 5 files changed, 192 insertions(+), 137 deletions(-) diff --git a/requestsync b/requestsync index a7be93f..0212668 100755 --- a/requestsync +++ b/requestsync @@ -43,43 +43,46 @@ from ubuntutools.requestsync.common import (edit_report, getDebianChangelog, if __name__ == '__main__': # Our usage options. - usage = 'Usage: %prog [options] ' \ - ' [ [base version]]' - optParser = OptionParser(usage) + usage = ('Usage: %prog [options] ' + ' [ [base version]]') + p = OptionParser(usage) - optParser.add_option('-d', type='string', - dest='dist', default='unstable', - help='Debian distribution to sync from.') - optParser.add_option('-k', type='string', - dest='keyid', default=None, - help='GnuPG key ID to use for signing report (only used when emailing the sync request).') - optParser.add_option('-n', action='store_true', - dest='newpkg', default=False, - help='Whether package to sync is a new package in Ubuntu.') - optParser.add_option('--lp', action='store_true', - dest='lpapi', default=False, - help='Specify whether to use the LP API for filing the sync request (recommended).') - optParser.add_option('-l', '--lpinstance', type='string', metavar='INSTANCE', - dest='lpinstance', default=None, - help='Launchpad instance to connect to (default: production).') - optParser.add_option('-s', action='store_true', - dest='sponsorship', default=False, - help='Force sponsorship') - optParser.add_option('-C', action='store_true', - dest='missing_changelog_ok', default=False, - help='Allow changelog to be manually filled in when missing') - optParser.add_option('-e', action='store_true', - dest='ffe', default=False, - help='Use this after FeatureFreeze for non-bug fix syncs, changes ' \ - 'default subscription to the appropriate release team.') - optParser.add_option('--no-conf', action='store_true', - dest='no_conf', default=False, - help="Don't read config files or environment variables") + p.add_option('-d', type='string', + dest='dist', default='unstable', + help='Debian distribution to sync from.') + p.add_option('-k', type='string', + dest='keyid', default=None, + help='GnuPG key ID to use for signing report ' + '(only used when emailing the sync request).') + p.add_option('-n', action='store_true', + dest='newpkg', default=False, + help='Whether package to sync is a new package in Ubuntu.') + p.add_option('--lp', action='store_true', + dest='lpapi', default=False, + help='Specify whether to use the LP API for filing ' + 'the sync request (recommended).') + p.add_option('-l', '--lpinstance', metavar='INSTANCE', + dest='lpinstance', default=None, + help='Launchpad instance to connect to (default: production).') + p.add_option('-s', action='store_true', + dest='sponsorship', default=False, + help='Force sponsorship') + p.add_option('-C', action='store_true', + dest='missing_changelog_ok', default=False, + help='Allow changelog to be manually filled in when missing') + p.add_option('-e', action='store_true', + dest='ffe', default=False, + help='Use this after FeatureFreeze for non-bug fix syncs, ' + 'changes default subscription to the appropriate ' + 'release team.') + p.add_option('--no-conf', action='store_true', + dest='no_conf', default=False, + help="Don't read config files or environment variables") - (options, args) = optParser.parse_args() + (options, args) = p.parse_args() if not len(args): - optParser.print_help() + p.print_help() sys.exit(1) config = UDTConfig(options.no_conf) @@ -89,14 +92,17 @@ if __name__ == '__main__': if options.lpinstance is None: options.lpinstance = config.get_value('LPINSTANCE') mailserver_host = config.get_value('SMTP_SERVER', - default='fiordland.ubuntu.com', - compat_keys=['UBUSMTP', 'DEBSMTP']) + default='fiordland.ubuntu.com', + compat_keys=['UBUSMTP', 'DEBSMTP']) 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', - compat_keys=['UBUSMTP_USER', 'DEBSMTP_USER']) + compat_keys=['UBUSMTP_USER', + 'DEBSMTP_USER']) mailserver_pass = config.get_value('SMTP_PASS', - compat_keys=['UBUSMTP_PASS', 'DEBSMTP_PASS']) + compat_keys=['UBUSMTP_PASS', + 'DEBSMTP_PASS']) # import the needed requestsync module if options.lpapi: @@ -105,7 +111,8 @@ if __name__ == '__main__': getUbuntuSrcPkg, needSponsorship, postBug) 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: Launchpad.login(service=options.lpinstance) @@ -144,7 +151,7 @@ if __name__ == '__main__': force_base_version = Version(args[2]) else: print >> sys.stderr, 'E: Too many arguments.' - optParser.print_help() + p.print_help() sys.exit(1) # Get the current Ubuntu source package @@ -158,9 +165,11 @@ if __name__ == '__main__': ubuntu_version = Version('~') ubuntu_component = 'universe' # let's assume universe if not newsource: - print "'%s' doesn't exist in 'Ubuntu %s'.\nDo you want to sync a new package?" % \ - (srcpkg, release) - raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ') + print ("'%s' doesn't exist in 'Ubuntu %s'.\n" + "Do you want to sync a new package?" + % (srcpkg, release)) + raw_input_exit_on_ctrlc('Press [Enter] to continue ' + 'or [Ctrl-C] to abort. ') newsource = True # Get the requested Debian source package @@ -177,7 +186,8 @@ if __name__ == '__main__': # try rmadison import ubuntutools.requestsync.mail try: - debian_srcpkg = ubuntutools.requestsync.mail.getDebianSrcPkg(srcpkg, distro) + debian_srcpkg = ubuntutools.requestsync.mail.getDebianSrcPkg( + srcpkg, distro) debian_version = Version(debian_srcpkg.getVersion()) debian_component = debian_srcpkg.getComponent() except udtexceptions.PackageNotFoundException, e: @@ -185,12 +195,14 @@ if __name__ == '__main__': sys.exit(1) if ubuntu_version == debian_version: - print >> sys.stderr, \ - 'E: The versions in Debian and Ubuntu are the same already (%s). Aborting.' % ubuntu_version + print >> sys.stderr, ('E: The versions in Debian and Ubuntu are the ' + 'same already (%s). Aborting.' + % ubuntu_version) sys.exit(1) if ubuntu_version > debian_version: - print >> sys.stderr, \ - 'E: The version in Ubuntu (%s) is newer than the version in Debian (%s). Aborting.' % (ubuntu_version, debian_version) + print >> sys.stderr, ('E: The version in Ubuntu (%s) is newer than ' + 'the version in Debian (%s). Aborting.' + % (ubuntu_version, debian_version)) sys.exit(1) # -s flag not specified - check if we do need sponsorship @@ -202,8 +214,9 @@ if __name__ == '__main__': checkExistingReports(srcpkg) # Generate bug report - pkg_to_sync = '%s %s (%s) from Debian %s (%s)' % \ - (srcpkg, debian_version, ubuntu_component, distro, debian_component) + pkg_to_sync = ('%s %s (%s) from Debian %s (%s)' + % (srcpkg, debian_version, ubuntu_component, + distro, debian_component)) title = "Sync %s" % pkg_to_sync if ffe: title = "FFe: " + title @@ -212,43 +225,50 @@ if __name__ == '__main__': if 'ubuntu' in str(ubuntu_version): need_interaction = True - print 'Changes have been made to the package in Ubuntu.\n' \ - 'Please edit the report and give an explanation.\n' \ - 'Not saving the report file will abort the request.' - report += 'Explanation of the Ubuntu delta and why it can be dropped:\n' \ - '>>> ENTER_EXPLANATION_HERE <<<\n\n' + print ('Changes have been made to the package in Ubuntu.\n' + 'Please edit the report and give an explanation.\n' + 'Not saving the report file will abort the request.') + report += ('Explanation of the Ubuntu delta and why it can be ' + 'dropped:\n>>> ENTER_EXPLANATION_HERE <<<\n\n') if ffe: need_interaction = True - print 'To approve FeatureFreeze exception, you need to state\n' \ - 'the reason why you feel it is necessary.\n' \ - 'Not saving the report file will abort the request.' - report += 'Explanation of FeatureFreeze exception:\n' \ - '>>> ENTER_EXPLANATION_HERE <<<\n\n' + print ('To approve FeatureFreeze exception, you need to state\n' + 'the reason why you feel it is necessary.\n' + 'Not saving the report file will abort the request.') + report += ('Explanation of FeatureFreeze exception:\n' + '>>> ENTER_EXPLANATION_HERE <<<\n\n') 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 if newsource: report += 'All changelog entries:\n\n' 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) if not changelog: 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) else: need_interaction = True changelog = "XXX FIXME: add changelog here XXX" 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: - 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) # bug status and bug subscriber diff --git a/ubuntu-build b/ubuntu-build index cee1ba3..c3755da 100755 --- a/ubuntu-build +++ b/ubuntu-build @@ -27,7 +27,8 @@ import sys from optparse import OptionGroup from optparse import OptionParser from ubuntutools.lp.udtexceptions import (SeriesNotFoundException, - PackageNotFoundException, PocketDoesNotExistError,) + PackageNotFoundException, + PocketDoesNotExistError,) from ubuntutools.lp.lpapicache import Distribution, PersonTeam from ubuntutools.misc import splitReleasePocket @@ -53,26 +54,28 @@ retryRescoreOptions.add_option("-a", "--arch", type = "string", "%s." % ", ".join(valid_archs)) # Batch processing options -batch_options = OptionGroup( - optParser, "Batch processing", +batch_options = OptionGroup(optParser, "Batch processing", "These options and parameter ordering is only available in --batch mode.\n" "Usage: ubuntu-build --batch [options] ...") -batch_options.add_option( - '--batch', action = 'store_true', dest = 'batch', default = False, - help = 'Enable batch mode') -batch_options.add_option( - '--series', action = 'store', dest = 'series', type = 'string', - help = 'Selects the Ubuntu series to operate on (default: current development series)') -batch_options.add_option( - '--retry', action = 'store_true', dest = 'retry', default = False, - help = 'Retry builds (give-back).') -batch_options.add_option( - '--rescore', action = 'store', dest = 'priority', type = 'int', - help = 'Rescore builds to .') -batch_options.add_option( - '--arch2', action = 'append', dest = 'architecture', type = 'string', - help = "Affect only 'architecture' (can be used several times). " - "Valid architectures are: %s." % ', '.join(valid_archs)) +batch_options.add_option('--batch', + action='store_true', dest='batch', default=False, + help='Enable batch mode') +batch_options.add_option('--series', + action='store', dest='series', type='string', + help='Selects the Ubuntu series to operate on ' + '(default: current development series)') +batch_options.add_option('--retry', + action='store_true', dest='retry', default=False, + help='Retry builds (give-back).') +batch_options.add_option('--rescore', + action='store', dest='priority', type='int', + help='Rescore builds to .') +batch_options.add_option('--arch2', + action='append', dest='architecture', type='string', + help="Affect only 'architecture' " + "(can be used several times). " + "Valid architectures are: %s." + % ', '.join(valid_archs)) # Add the retry options to the main group. optParser.add_option_group(retryRescoreOptions) @@ -104,11 +107,12 @@ if not options.batch: print >> sys.stderr, "Invalid operation: %s." % op sys.exit(1) - # If the user has specified an architecture to build, we only wish to rebuild it - # and nothing else. + # If the user has specified an architecture to build, we only wish to + # rebuild it and nothing else. if options.architecture: 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) else: oneArch = True @@ -142,21 +146,26 @@ if not options.batch: version = sources.getVersion() component = sources.getComponent() - # Operations that are remaining may only be done by Ubuntu developers (retry) - # or buildd admins (rescore). Check if the proper permissions are in place. + # 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 = PersonTeam.me - if op == "rescore": necessaryPrivs = me.isLpTeamMember('launchpad-buildd-admins') - if op == "retry": necessaryPrivs = me.canUploadPackage( - ubuntu_archive, distroseries, sources.getPackageName(), sources.getComponent()) + if op == "rescore": + necessaryPrivs = me.isLpTeamMember('launchpad-buildd-admins') + if op == "retry": + necessaryPrivs = me.canUploadPackage(ubuntu_archive, distroseries, + sources.getPackageName(), + sources.getComponent()) if op in ('rescore', 'retry') and not necessaryPrivs: - print >> sys.stderr, "You cannot perform the %s operation on a %s package " \ - "as you do not have the permissions to do this action." % (op, component) + print >> sys.stderr, ("You cannot perform the %s operation on a %s " + "package as you do not have the permissions to " + "do this action." % (op, component)) sys.exit(1) # Output details. - print "The source version for '%s' in %s (%s) is at %s." % (package, - release.capitalize(), component, version) + print ("The source version for '%s' in %s (%s) is at %s." + % (package, release.capitalize(), component, version)) print "Current build status for this package:" @@ -188,8 +197,8 @@ if not options.batch: # We are done if done: sys.exit(0) - print "No builds for '%s' found in the %s release - it may have been " \ - "built in a former release." % (package, release.capitalize()) + print ("No builds for '%s' found in the %s release - it may have been " + "built in a former release." % (package, release.capitalize())) sys.exit(0) # Batch mode @@ -219,9 +228,12 @@ except SeriesNotFoundException, e: me = PersonTeam.me # 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: - 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: try: @@ -230,10 +242,16 @@ for pkg in args: print e continue - # Check permissions (part 2): check upload permissions for the source package - can_retry = options.retry and me.canUploadPackage(ubuntu_archive, distroseries, pkg.getPackageName(), pkg.getComponent()) + # Check permissions (part 2): check upload permissions for the source + # package + can_retry = options.retry and me.canUploadPackage(ubuntu_archive, + distroseries, + pkg.getPackageName(), + pkg.getComponent()) 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" % ( pkg.getPackageName(), release, pocket, pkg.getVersion()) diff --git a/ubuntutools/requestsync/common.py b/ubuntutools/requestsync/common.py index 66795ef..ec3cbce 100644 --- a/ubuntutools/requestsync/common.py +++ b/ubuntutools/requestsync/common.py @@ -54,11 +54,13 @@ def getDebianChangelog(srcpkg, version): # Get the debian changelog file from packages.debian.org try: - changelog = urllib2.urlopen( - 'http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog.txt' % \ - (component, subdir, pkgname, pkgname, pkgversion)) + changelog = urllib2.urlopen('http://packages.debian.org/changelogs/pool' + '/%s/%s/%s/%s_%s/changelog.txt' + % (component, subdir, pkgname, pkgname, + pkgversion)) 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 new_entries = '' @@ -88,7 +90,8 @@ def edit_report(subject, body, changes_required = False): if not changes_required: print 'Currently the report looks as follows:\n%s' % report 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'): break elif val.lower() in ('n', 'no', ''): @@ -108,15 +111,17 @@ def edit_report(subject, body, changes_required = False): try: subprocess.check_call(['sensible-editor', report_file.name]) 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) # Check if the tempfile has been changed if changes_required: if mtime_before == os.stat(report_file.name).st_mtime: - print 'The report has not been changed, but you have to explain why ' \ - 'the Ubuntu changes can be dropped.' - raw_input_exit_on_ctrlc('Press [Enter] to retry or [Control-C] to abort. ') + print ('The report has not been changed, but you have to ' + 'explain why the Ubuntu changes can be dropped.') + raw_input_exit_on_ctrlc('Press [Enter] to retry or ' + '[Control-C] to abort. ') else: changes_required = False @@ -127,6 +132,7 @@ def edit_report(subject, body, changes_required = False): # Undecorate report again (subject, body) = report.split("\nDescription:\n", 1) # 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) diff --git a/ubuntutools/requestsync/lp.py b/ubuntutools/requestsync/lp.py index d8b22c8..1be7339 100644 --- a/ubuntutools/requestsync/lp.py +++ b/ubuntutools/requestsync/lp.py @@ -21,7 +21,8 @@ # of the GNU General Public License license. 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 def getDebianSrcPkg(name, release): @@ -51,7 +52,8 @@ def needSponsorship(name, component, release): archive = Distribution('ubuntu').getArchive() 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: 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 @@ -77,18 +79,22 @@ def checkExistingReports(srcpkg): for bug in pkgBugList: # check for Sync or sync and the package name 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 ' * %s (%s)' % \ - (bug.title, translate_api_web(bug.self_link)) - print 'Please check the above URL to verify this before continuing.' - raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ') + print ('The following bug could be a possible duplicate sync bug ' + 'on Launchpad:\n' + ' * %s (%s)\n' + 'Please check the above URL to verify this before ' + '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): ''' 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. ') if srcpkg: @@ -99,7 +105,8 @@ def postBug(srcpkg, subscribe, status, bugtitle, bugtext): bug_target = Distribution('ubuntu') # 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 task = bug.bug_tasks[0] @@ -111,5 +118,5 @@ def postBug(srcpkg, subscribe, status, bugtitle, bugtext): bug.subscribe(person = PersonTeam(subscribe)()) - print 'Sync request filed as bug #%i: %s' % (bug.id, - translate_api_web(bug.self_link)) + print ('Sync request filed as bug #%i: %s' + % (bug.id, translate_api_web(bug.self_link))) diff --git a/ubuntutools/requestsync/mail.py b/ubuntutools/requestsync/mail.py index b9bf279..157d6e3 100644 --- a/ubuntutools/requestsync/mail.py +++ b/ubuntutools/requestsync/mail.py @@ -34,7 +34,7 @@ __all__ = [ 'needSponsorship', 'checkExistingReports', 'mailBug', - ] +] class SourcePackagePublishingHistory(object): ''' @@ -64,9 +64,9 @@ def rmadison(distro, package, release): } release = releasenames.get(release, release) - rmadison_cmd = subprocess.Popen( - ['rmadison', '-u', distro, '-a', 'source', '-s', release, package], - stdout = subprocess.PIPE) + rmadison_cmd = subprocess.Popen(['rmadison', '-u', distro, '-a', 'source', + '-s', release, package], + stdout=subprocess.PIPE) rmadison_out = rmadison_cmd.communicate()[0] assert (rmadison_cmd.returncode == 0) @@ -87,9 +87,9 @@ def rmadison(distro, package, release): def getSrcPkg(distro, name, release): out = rmadison(distro, name, release) if not out: - raise PackageNotFoundException( - "'%s' doesn't appear to exist in %s '%s'" % \ - (name, distro.capitalize(), release)) + raise PackageNotFoundException("'%s' doesn't appear to exist " + "in %s '%s'" + % (name, distro.capitalize(), release)) version = out[1] component = 'main' @@ -112,8 +112,9 @@ def needSponsorship(name, component, release): ''' while True: - print "Do you have upload permissions for the '%s' component " \ - "or the package '%s' in Ubuntu %s?" % (component, name, release) + print ("Do you have upload permissions for the '%s' component " + "or the package '%s' in Ubuntu %s?" + % (component, name, release)) val = raw_input_exit_on_ctrlc("If in doubt answer 'n'. [y/N]? ") if val.lower() in ('y', 'yes'): return False @@ -126,8 +127,9 @@ def checkExistingReports(srcpkg): ''' 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' \ - 'for duplicate sync requests before continuing.' % srcpkg + print ('Please check on ' + '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. ') 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)) # 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') assert gpg.returncode == 0 @@ -199,7 +202,8 @@ Content-Type: text/plain; charset=UTF-8 try: s.login(mailserver_user, mailserver_pass) 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() return except: