mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 15:41:09 +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:
|
||||
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',
|
||||
default='',
|
||||
default=None,
|
||||
compat_keys=['UBUSMTP', 'DEBSMTP'])
|
||||
if not mailserver_host:
|
||||
if not options.lpapi and not mailserver_host:
|
||||
try:
|
||||
import DNS
|
||||
DNS.DiscoverNameServers()
|
||||
mxlist = DNS.mxlookup('launchpad.net')
|
||||
mxlist = DNS.mxlookup(bug_mail_domain)
|
||||
firstmx = mxlist[0]
|
||||
mx1host = firstmx[1]
|
||||
mailserver_host = config.get_value('SMTP_SERVER',
|
||||
default=mx1host,
|
||||
compat_keys=['UBUSMTP', 'DEBSMTP'])
|
||||
mailserver_host = firstmx[1]
|
||||
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,
|
||||
compat_keys=['UBUSMTP_PORT',
|
||||
@ -309,7 +317,7 @@ def main():
|
||||
else:
|
||||
email_from = ubu_email(export=False)[1]
|
||||
# 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,
|
||||
mailserver_user, mailserver_pass)
|
||||
|
||||
|
@ -81,20 +81,14 @@ def checkExistingReports(srcpkg):
|
||||
'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,
|
||||
myemailaddr, mailserver_host, mailserver_port, mailserver_user,
|
||||
mailserver_pass):
|
||||
def mailBug(srcpkg, subscribe, status, bugtitle, bugtext, bug_mail_domain,
|
||||
keyid, myemailaddr, mailserver_host, mailserver_port,
|
||||
mailserver_user, mailserver_pass):
|
||||
'''
|
||||
Submit the sync request per email.
|
||||
'''
|
||||
|
||||
if lpinstance == 'production':
|
||||
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)
|
||||
to = 'new@' + bug_mail_domain
|
||||
|
||||
# generate mailbody
|
||||
if srcpkg:
|
||||
|
Loading…
x
Reference in New Issue
Block a user