mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
Rework Scott's requestsync modifications for robustness and staging-support
This commit is contained in:
parent
f8f79ecf99
commit
773c5c33e0
28
requestsync
28
requestsync
@ -96,22 +96,30 @@ def main():
|
|||||||
if options.lpinstance is None:
|
if options.lpinstance is None:
|
||||||
options.lpinstance = config.get_value('LPINSTANCE')
|
options.lpinstance = config.get_value('LPINSTANCE')
|
||||||
|
|
||||||
|
if not options.lpapi:
|
||||||
|
if options.lpinstance == 'production':
|
||||||
|
bug_mail_domain = 'bugs.launchpad.net'
|
||||||
|
elif options.lpinstance == 'staging':
|
||||||
|
bug_mail_domain = 'bugs.staging.launchpad.net'
|
||||||
|
else:
|
||||||
|
print >> sys.stderr, ('Error: Unknown launchpad instance: %s'
|
||||||
|
% options.lpinstance)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
mailserver_host = config.get_value('SMTP_SERVER',
|
mailserver_host = config.get_value('SMTP_SERVER',
|
||||||
default='',
|
default=None,
|
||||||
compat_keys=['UBUSMTP', 'DEBSMTP'])
|
compat_keys=['UBUSMTP', 'DEBSMTP'])
|
||||||
if not mailserver_host:
|
if not options.lpapi and not mailserver_host:
|
||||||
try:
|
try:
|
||||||
import DNS
|
import DNS
|
||||||
DNS.DiscoverNameServers()
|
DNS.DiscoverNameServers()
|
||||||
mxlist = DNS.mxlookup('launchpad.net')
|
mxlist = DNS.mxlookup(bug_mail_domain)
|
||||||
firstmx = mxlist[0]
|
firstmx = mxlist[0]
|
||||||
mx1host = firstmx[1]
|
mailserver_host = firstmx[1]
|
||||||
mailserver_host = config.get_value('SMTP_SERVER',
|
|
||||||
default=mx1host,
|
|
||||||
compat_keys=['UBUSMTP', 'DEBSMTP'])
|
|
||||||
except ImportError, x:
|
except ImportError, x:
|
||||||
print "Please install python-dns to support Launchapd mail server lookup."
|
print >> sys.stderr, ('Please install python-dns to support '
|
||||||
|
'Launchpad mail server lookup.')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
mailserver_port = config.get_value('SMTP_PORT', default=25,
|
mailserver_port = config.get_value('SMTP_PORT', default=25,
|
||||||
compat_keys=['UBUSMTP_PORT',
|
compat_keys=['UBUSMTP_PORT',
|
||||||
@ -309,7 +317,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
email_from = ubu_email(export=False)[1]
|
email_from = ubu_email(export=False)[1]
|
||||||
# Mail sync request
|
# Mail sync request
|
||||||
mailBug(srcpkg, subscribe, status, title, report, options.lpinstance,
|
mailBug(srcpkg, subscribe, status, title, report, bug_mail_domain,
|
||||||
options.keyid, email_from, mailserver_host, mailserver_port,
|
options.keyid, email_from, mailserver_host, mailserver_port,
|
||||||
mailserver_user, mailserver_pass)
|
mailserver_user, mailserver_pass)
|
||||||
|
|
||||||
|
@ -81,20 +81,14 @@ def checkExistingReports(srcpkg):
|
|||||||
'for duplicate sync requests before continuing.' % srcpkg)
|
'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, bug_mail_domain,
|
||||||
myemailaddr, mailserver_host, mailserver_port, mailserver_user,
|
keyid, myemailaddr, mailserver_host, mailserver_port,
|
||||||
mailserver_pass):
|
mailserver_user, mailserver_pass):
|
||||||
'''
|
'''
|
||||||
Submit the sync request per email.
|
Submit the sync request per email.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if lpinstance == 'production':
|
to = 'new@' + bug_mail_domain
|
||||||
to = 'new@bugs.launchpad.net'
|
|
||||||
elif lpinstance == 'staging':
|
|
||||||
to = 'new@bugs.staging.launchpad.net'
|
|
||||||
else:
|
|
||||||
print >> sys.stderr, 'Error: Unknown launchpad instance:', lpinstance
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# generate mailbody
|
# generate mailbody
|
||||||
if srcpkg:
|
if srcpkg:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user