Commits

Josh VanderLinden committed 88ab242

Added some safety features to the articles from email code

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):
         """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.