copied bit of error handling from Carl

This commit is contained in:
steffen123 2010-07-07 08:17:18 +02:00
parent 0ecd19fbdf
commit 1bf3827921

View File

@ -30,12 +30,14 @@ def splitPokerStarsSummaries(emailText):
return splitSummaries return splitSummaries
#end def emailText #end def emailText
if __name__ == '__main__':
#TODO: move all these into the config file. until then usage is: ./ImapSummaries.py YourImapHost YourImapUser YourImapPw #TODO: move all these into the config file. until then usage is: ./ImapSummaries.py YourImapHost YourImapUser YourImapPw
configHost=sys.argv[1] configHost=sys.argv[1]
configUser=sys.argv[2] configUser=sys.argv[2]
configPw=sys.argv[3] configPw=sys.argv[3]
#TODO: specify folder, whether to use SSL #TODO: specify folder, whether to use SSL
try:
server = IMAP4_SSL(configHost) #TODO: optionally non-SSL server = IMAP4_SSL(configHost) #TODO: optionally non-SSL
response = server.login(configUser, configPw) #TODO catch authentication error response = server.login(configUser, configPw) #TODO catch authentication error
#print "response to logging in:",response #print "response to logging in:",response
@ -71,5 +73,10 @@ for messageData in neededMessages:
#TODO: count results and output to shell like hand importer does #TODO: count results and output to shell like hand importer does
print "completed running Imap import, closing server connection" print "completed running Imap import, closing server connection"
finally:
try:
server.close() server.close()
finally:
pass
server.logout() server.logout()