|  | @@ -109,32 +109,32 @@ class MailFetcher(object):
 | 
	
		
			
			| 109 | 109 |      def run(self):
 | 
	
		
			
			| 110 | 110 |          while self._is_active:
 | 
	
		
			
			| 111 | 111 |              time.sleep(self.delay)
 | 
	
		
			
			| 112 |  | -            if self._connect():
 | 
	
		
			
			| 113 |  | -                self._fetch()
 | 
	
		
			
			| 114 |  | -                self._notify_tracim()
 | 
	
		
			
			| 115 |  | -                self._disconnect()
 | 
	
		
			
			|  | 112 | +            self._connect()
 | 
	
		
			
			|  | 113 | +            self._fetch()
 | 
	
		
			
			|  | 114 | +            self._notify_tracim()
 | 
	
		
			
			|  | 115 | +            self._disconnect()
 | 
	
		
			
			| 116 | 116 |  
 | 
	
		
			
			| 117 | 117 |      def stop(self):
 | 
	
		
			
			| 118 | 118 |          self._is_active = False
 | 
	
		
			
			| 119 | 119 |  
 | 
	
		
			
			| 120 | 120 |      def _connect(self):
 | 
	
		
			
			| 121 | 121 |          ## verify if connected ?
 | 
	
		
			
			| 122 |  | -        if not self._connection:
 | 
	
		
			
			| 123 |  | -            # TODO: Support unencrypted connection ?
 | 
	
		
			
			| 124 |  | -            # TODO: Support keyfile,certfile ?
 | 
	
		
			
			| 125 |  | -            self._connection = imaplib.IMAP4_SSL(self.host,self.port)
 | 
	
		
			
			| 126 |  | -            try:
 | 
	
		
			
			| 127 |  | -                rv, data = self._connection.login(self.user,self.password)
 | 
	
		
			
			| 128 |  | -                return True
 | 
	
		
			
			| 129 |  | -            except Exception as e:
 | 
	
		
			
			| 130 |  | -                log = 'IMAP login error: {}'
 | 
	
		
			
			| 131 |  | -                logger.debug(self, log.format(e.__str__()))
 | 
	
		
			
			| 132 |  | -                self._connection = None
 | 
	
		
			
			| 133 |  | -                return False
 | 
	
		
			
			| 134 |  | -        return False
 | 
	
		
			
			|  | 122 | +        if self._connection:
 | 
	
		
			
			|  | 123 | +            self._disconnect()
 | 
	
		
			
			|  | 124 | +        # TODO: Support unencrypted connection ?
 | 
	
		
			
			|  | 125 | +        # TODO: Support keyfile,certfile ?
 | 
	
		
			
			|  | 126 | +        self._connection = imaplib.IMAP4_SSL(self.host,self.port)
 | 
	
		
			
			|  | 127 | +        try:
 | 
	
		
			
			|  | 128 | +            rv, data = self._connection.login(self.user,self.password)
 | 
	
		
			
			|  | 129 | +        except Exception as e:
 | 
	
		
			
			|  | 130 | +            log = 'IMAP login error: {}'
 | 
	
		
			
			|  | 131 | +            logger.debug(self, log.format(e.__str__()))
 | 
	
		
			
			|  | 132 | +
 | 
	
		
			
			| 135 | 133 |      def _disconnect(self):
 | 
	
		
			
			| 136 | 134 |          if self._connection:
 | 
	
		
			
			|  | 135 | +            self._connection.close()
 | 
	
		
			
			| 137 | 136 |              self._connection.logout()
 | 
	
		
			
			|  | 137 | +            self._connection = None
 | 
	
		
			
			| 138 | 138 |  
 | 
	
		
			
			| 139 | 139 |      def _fetch(self):
 | 
	
		
			
			| 140 | 140 |          """
 |