1
0
Fork 0
mirror of https://git.code.sf.net/p/archivemail/code synced 2025-03-11 23:32:48 +00:00

Tightened some blanket exception handlers.

This commit is contained in:
Nikolaus Schulz 2006-11-01 19:49:47 +00:00
parent e872f2211e
commit c5f194f3ec

View file

@ -1301,15 +1301,15 @@ def _archive_imap(mailbox_name, final_archive_name):
try: try:
imap_username, imap_str = imap_str.split('@', 1) imap_username, imap_str = imap_str.split('@', 1)
imap_server, imap_folder = imap_str.split('/', 1) imap_server, imap_folder = imap_str.split('/', 1)
except: except ValueError:
unexpected_error("you must provide a properly formatted \ unexpected_error("you must provide a properly formatted "
IMAP connection string") "IMAP connection string")
if options.pwfile: if options.pwfile:
imap_password = open(options.pwfile).read().rstrip() imap_password = open(options.pwfile).read().rstrip()
else: else:
try: try:
imap_username, imap_password = imap_username.split(':', 1) imap_username, imap_password = imap_username.split(':', 1)
except: except ValueError:
imap_password = getpass.getpass() imap_password = getpass.getpass()
if mailbox_name[:5] == 'imaps': if mailbox_name[:5] == 'imaps':
@ -1320,7 +1320,7 @@ def _archive_imap(mailbox_name, final_archive_name):
vprint("connected to server %s" % imap_server) vprint("connected to server %s" % imap_server)
try: try:
result, response = imap_srv.login_cram_md5(imap_username, imap_password) result, response = imap_srv.login_cram_md5(imap_username, imap_password)
except: except imaplib.IMAP4.error:
result, response = imap_srv.login(imap_username, imap_password) result, response = imap_srv.login(imap_username, imap_password)
if result != 'OK': unexpected_error("authentication failure") if result != 'OK': unexpected_error("authentication failure")
vprint("logged in to server as %s" % imap_username) vprint("logged in to server as %s" % imap_username)