#NEWLINE# def _parse_mailboxes( self , mailboxes ) : #NEWLINE# #INDENT# for ( mailbox , config ) in mailboxes . items ( ) : #NEWLINE# #INDENT# server = config . get ( 'server' , 'localhost' ) #NEWLINE# port = config . get ( 'port' , 143 ) #NEWLINE# user = config . get ( 'username' , None ) #NEWLINE# password = config . get ( 'password' , None ) #NEWLINE# folder = config . get ( 'mailbox' , 'INBOX' ) #NEWLINE# ssl = config . get ( 'ssl' , False ) #NEWLINE# download_attachments = config . get ( 'download_attachments' , DEFAULT_DOWNLOAD_ATTACHMENTS ) #NEWLINE# if ( ( not user ) or ( not password ) ) : #NEWLINE# #INDENT# self . _logger . debug ( '[IMAPSensor]: Missing\n                    username/password for {0}' . format ( mailbox ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( not server ) : #NEWLINE# #INDENT# self . _logger . debug ( '[IMAPSensor]: Missing server\n                    for {0}' . format ( mailbox ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# connection = easyimap . connect ( server , user , password , folder , ssl = ssl , port = port ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# message = ( 'Failed to connect to mailbox "%s": %s' % ( mailbox , str ( e ) ) ) #NEWLINE# raise Exception ( message ) #NEWLINE# #UNINDENT# item = { #NEWLINE# #INDENT# 'connection' : connection , #NEWLINE# 'download_attachments' : download_attachments , #NEWLINE# 'mailbox_metadata' : { #NEWLINE# #INDENT# 'server' : server , #NEWLINE# 'port' : folder , #NEWLINE# 'user' : user , #NEWLINE# 'folder' : folder , #NEWLINE# 'ssl' : ssl , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# self . _mailboxes [ mailbox ] = item