mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-20 13:21:28 +00:00
requestsync: reindent remaining code and small cleanup
This commit is contained in:
parent
d5a19ca5a7
commit
966ab3727a
106
requestsync
106
requestsync
@ -26,76 +26,76 @@
|
|||||||
#
|
#
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
from debian_bundle.changelog import Version
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from debian_bundle.changelog import Version
|
||||||
|
|
||||||
# ubuntu-dev-tools modules.
|
# ubuntu-dev-tools modules
|
||||||
import ubuntutools.lp.libsupport as lp_libsupport
|
from ubuntutools.lp import udtexceptions
|
||||||
import ubuntutools.lp.udtexceptions as udtexceptions
|
from ubuntutools.requestsync.common import *
|
||||||
from ubuntutools.lp.lpapicache import Launchpad, LpApiWrapper, Distribution, PersonTeam
|
|
||||||
# https_proxy fix
|
# https_proxy fix
|
||||||
import ubuntutools.common
|
import ubuntutools.common
|
||||||
|
|
||||||
from ubuntutools.requestsync.mail import *
|
|
||||||
from ubuntutools.requestsync.common import *
|
|
||||||
from ubuntutools.requestsync.lp import postBug
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# entry point
|
# entry point
|
||||||
#
|
#
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Our usage options.
|
# Our usage options.
|
||||||
usage = "Usage: %prog [-d distro] [-k keyid] [-n] [--lp] [-s] [-e] "
|
usage = 'Usage: %prog [-d distro] [-k keyid] [-n] [--lp] [-s] [-e] ' \
|
||||||
usage += "<source package> [<target release> [base version]]"
|
'<source package> [<target release> [base version]]'
|
||||||
optParser = OptionParser(usage)
|
optParser = OptionParser(usage)
|
||||||
|
|
||||||
optParser.add_option("-d", type = "string",
|
optParser.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",
|
optParser.add_option('-k', type = 'string',
|
||||||
dest = "keyid", default = None,
|
dest = 'keyid', default = None,
|
||||||
help = "GnuPG key ID to use for signing report.")
|
help = 'GnuPG key ID to use for signing report (only used when emailing the sync request).')
|
||||||
optParser.add_option("-n", action = "store_true",
|
optParser.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",
|
optParser.add_option('--lp', action = 'store_true',
|
||||||
dest = "lpbugs", default = False,
|
dest = 'lpapi', default = False,
|
||||||
help = "Specify whether to use the launchpadlib module for filing " \
|
help = 'Specify whether to use the LP API for filing the sync request.')
|
||||||
"report.")
|
optParser.add_option('-s', action = 'store_true',
|
||||||
optParser.add_option("-s", action = "store_true",
|
dest = 'sponsor', default = False,
|
||||||
dest = "sponsor", default = False,
|
help = 'Force sponsorship')
|
||||||
help = "Force sponsorship requirement (shall be autodetected if not " \
|
optParser.add_option('-e', action = 'store_true',
|
||||||
"specified).")
|
dest = 'ffe', default = False,
|
||||||
optParser.add_option("-e", action = "store_true",
|
help = 'Use this after FeatureFreeze for non-bug fix syncs, changes ' \
|
||||||
dest = "ffe", default = False,
|
'default subscription to the appropriate release team.')
|
||||||
help = "Use this after FeatureFreeze for non-bug fix syncs, changes " \
|
|
||||||
"default subscription to the appropriate release team.")
|
|
||||||
|
|
||||||
(options, args) = optParser.parse_args()
|
(options, args) = optParser.parse_args()
|
||||||
|
|
||||||
|
if not len(args):
|
||||||
|
optParser.print_help()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# import the needed requestsync module
|
||||||
|
if options.lpapi:
|
||||||
|
from ubuntutools.requestsync.lp import *
|
||||||
|
from ubuntutools.lp.lpapicache import Distribution
|
||||||
|
else:
|
||||||
|
from ubuntutools.requestsync.mail import *
|
||||||
|
if not getEmailAddress():
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
newsource = options.newpkg
|
newsource = options.newpkg
|
||||||
sponsorship = options.sponsor
|
sponsorship = options.sponsor
|
||||||
keyid = options.keyid
|
keyid = options.keyid
|
||||||
use_lp_bugs = options.lpbugs
|
lpapi = options.lpapi
|
||||||
need_interaction = False
|
need_interaction = False
|
||||||
distro = options.dist
|
distro = options.dist
|
||||||
ffe = options.ffe
|
ffe = options.ffe
|
||||||
|
|
||||||
if not use_lp_bugs and not getEmailAddress():
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if len(args) == 0:
|
|
||||||
optParser.print_help()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if len(args) not in (2, 3): # no release specified, assume development release
|
if len(args) not in (2, 3): # no release specified, assume development release
|
||||||
|
if options.lpapi:
|
||||||
release = Distribution('ubuntu').getDevelopmentSeries().name
|
release = Distribution('ubuntu').getDevelopmentSeries().name
|
||||||
print >> sys.stderr, ("Source package / target release missing - assuming %s " %
|
print >> sys.stderr, 'W: Target release missing - assuming %s' % release
|
||||||
release)
|
else:
|
||||||
|
print >> sys.stderr, 'E: Source package or target release missing. Exiting.'
|
||||||
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
release = args[1]
|
release = args[1]
|
||||||
|
|
||||||
@ -155,7 +155,6 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
subscribe = 'motu-release'
|
subscribe = 'motu-release'
|
||||||
|
|
||||||
|
|
||||||
pkg_to_sync = '%s %s (%s) from Debian %s (%s)' % (srcpkg, deb_version, component, distro, debiancomponent)
|
pkg_to_sync = '%s %s (%s) from Debian %s (%s)' % (srcpkg, deb_version, component, distro, debiancomponent)
|
||||||
title = "Sync %s" % pkg_to_sync
|
title = "Sync %s" % pkg_to_sync
|
||||||
if ffe == True:
|
if ffe == True:
|
||||||
@ -187,7 +186,6 @@ if __name__ == '__main__':
|
|||||||
report += 'Explanation of FeatureFreeze exception:\n' + \
|
report += 'Explanation of FeatureFreeze exception:\n' + \
|
||||||
'>>> ENTER_EXPLANATION_HERE <<<\n\n'
|
'>>> ENTER_EXPLANATION_HERE <<<\n\n'
|
||||||
|
|
||||||
|
|
||||||
# Check if they have a per-package upload permission.
|
# Check if they have a per-package upload permission.
|
||||||
if LpApiWrapper.isPerPackageUploader(srcpkg):
|
if LpApiWrapper.isPerPackageUploader(srcpkg):
|
||||||
report += 'Note that I have per-package upload permissions for %s.\n\n' % srcpkg
|
report += 'Note that I have per-package upload permissions for %s.\n\n' % srcpkg
|
||||||
@ -209,18 +207,10 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# Post sync request using Launchpad interface:
|
# Post sync request using Launchpad interface:
|
||||||
srcpkg = not newsource and srcpkg or None
|
srcpkg = not newsource and srcpkg or None
|
||||||
if use_lp_bugs:
|
if options.lpapi:
|
||||||
# Map status to the values expected by lp-bugs
|
# Map status to the values expected by lp-bugs
|
||||||
mapping = {'new': 'New', 'confirmed': 'Confirmed'}
|
mapping = {'new': 'New', 'confirmed': 'Confirmed'}
|
||||||
if postBug(srcpkg, subscribe, mapping[status], title, report):
|
postBug(srcpkg, subscribe, mapping[status], title, report)
|
||||||
sys.exit(0)
|
else:
|
||||||
# Abort on error:
|
|
||||||
print 'Something went wrong. No sync request filed.'
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Mail sync request:
|
# Mail sync request:
|
||||||
if mailBug(srcpkg, subscribe, status, title, report, keyid):
|
mailBug(srcpkg, subscribe, status, title, report, keyid)
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
print 'Something went wrong. No sync request filed.'
|
|
||||||
sys.exit(1)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user