Commits

Josh VanderLinden committed 88ab242

Added some safety features to the articles from email code

  • Participants
  • Parent commits c9ab023

Comments (0)

Files changed (1)

articles/management/commands/check_for_articles_from_email.py

 MB_POP3 = 'POP3'
 
 class MailboxHandler(object):
+
     def __init__(self, host, port, username, password, keyfile, certfile, ssl):
         self.host = host
         self.port = port
                 self.port = self.unsecure_port
 
     @property
+    def secure_port(self):
+        return -1
+
+    @property
+    def unsecure_port(self):
+        return -1
+
+    @property
     def handle(self):
         if not self._handle:
             self._handle = self.connect()
 
             self.log('Fetching messages')
             messages = handle.fetch()
-
             created = self.create_articles(messages)
 
             self.log('Deleting consumed messages')
             self.log('Failed to communicate with mail server.  Please verify your settings.', 0)
         finally:
             if handle:
-                handle.disconnect()
+                try:
+                    handle.disconnect()
+                except socket.error:
+                    # probably means we couldn't connect to begin with
+                    pass
 
     def get_mail_handle(self, protocol, *args, **kwargs):
         """