mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-16 01:21:07 +00:00
Save a temporary file in case sending fails
This commit is contained in:
parent
d9c00752c0
commit
10e9b18ca7
@ -162,6 +162,16 @@ Content-Type: text/plain; charset=UTF-8
|
|||||||
print 'The final report is:\n%s' % mail
|
print 'The final report is:\n%s' % mail
|
||||||
confirmation_prompt()
|
confirmation_prompt()
|
||||||
|
|
||||||
|
# save mail in temporary file
|
||||||
|
f=open("/tmp/requestsync-" + srcpkg,"w")
|
||||||
|
f.write(mail)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
print '''
|
||||||
|
The e-mail has been saved in %s and will be deleted
|
||||||
|
after succesful transmission
|
||||||
|
''' % f.name
|
||||||
|
|
||||||
# connect to the server
|
# connect to the server
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -176,8 +186,8 @@ Content-Type: text/plain; charset=UTF-8
|
|||||||
Logger.error('Could not connect to %s:%s: %s (%i)',
|
Logger.error('Could not connect to %s:%s: %s (%i)',
|
||||||
mailserver_host, mailserver_port, s[1], s[0])
|
mailserver_host, mailserver_port, s[1], s[0])
|
||||||
if s.smtp_code == 421:
|
if s.smtp_code == 421:
|
||||||
confirmation_prompt(message='This is a temporary error, press'
|
confirmation_prompt(message='This is a temporary error, press '
|
||||||
'[Enter] to retry. Press [Ctrl-C] to abort now.')
|
'[Enter] to retry. Press [Ctrl-C] to abort now.')
|
||||||
|
|
||||||
if mailserver_user and mailserver_pass:
|
if mailserver_user and mailserver_pass:
|
||||||
try:
|
try:
|
||||||
@ -192,6 +202,10 @@ Content-Type: text/plain; charset=UTF-8
|
|||||||
s.quit()
|
s.quit()
|
||||||
return
|
return
|
||||||
|
|
||||||
s.sendmail(myemailaddr, to, mail.encode('utf-8'))
|
try:
|
||||||
s.quit()
|
s.sendmail(myemailaddr, to, mail.encode('utf-8'))
|
||||||
Logger.normal('Sync request mailed.')
|
s.quit()
|
||||||
|
os.remove(f.name)
|
||||||
|
Logger.normal('Sync request mailed.')
|
||||||
|
except:
|
||||||
|
Logger.error('Unknown error while sending the mail.')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user