From e14685e3e73767d2d68d22e331b304528928bb54 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 1 Nov 2019 21:23:51 -0400 Subject: [PATCH] Rename instances of the IMAP server variable Renamed from mailbox to server for clarity. Signed-off-by: Roberto Rosario --- HISTORY.rst | 2 ++ mayan/apps/sources/models/email_sources.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 99d5c63666..4c0c007e44 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -38,6 +38,8 @@ - Add savesettings command. - Add extra logging to the IMAP email source. GitLab issue #682. Thanks to Patrick Hütter (@PatrickHuetter) for the report. +- Rename all instances of the IMAP server from mailbox to + server for clarity. 3.2.8 (2019-10-01) ================== diff --git a/mayan/apps/sources/models/email_sources.py b/mayan/apps/sources/models/email_sources.py index d74347f206..dd1b18b846 100644 --- a/mayan/apps/sources/models/email_sources.py +++ b/mayan/apps/sources/models/email_sources.py @@ -234,13 +234,13 @@ class IMAPEmail(EmailBaseModel): logger.debug('ssl: %s', self.ssl) if self.ssl: - mailbox = imaplib.IMAP4_SSL(host=self.host, port=self.port) + server = imaplib.IMAP4_SSL(host=self.host, port=self.port) else: - mailbox = imaplib.IMAP4(host=self.host, port=self.port) + server = imaplib.IMAP4(host=self.host, port=self.port) - mailbox.login(user=self.username, password=self.password) + server.login(user=self.username, password=self.password) try: - mailbox.select(mailbox=self.mailbox) + server.select(mailbox=self.mailbox) except Exception as exception: raise SourceException( 'Error selecting mailbox: {}; {}'.format( @@ -249,7 +249,7 @@ class IMAPEmail(EmailBaseModel): ) try: - status, data = mailbox.search(None, 'NOT', 'DELETED') + status, data = server.search(None, 'NOT', 'DELETED') except Exception as exception: raise SourceException( 'Error executing search command; {}'.format(exception) @@ -261,7 +261,7 @@ class IMAPEmail(EmailBaseModel): for message_number in messages_info: logger.debug('message_number: %s', message_number) - status, data = mailbox.fetch( + status, data = server.fetch( message_set=message_number, message_parts='(RFC822)' ) try: @@ -277,7 +277,7 @@ class IMAPEmail(EmailBaseModel): if not test: try: - mailbox.store( + server.store( message_set=message_number, command='+FLAGS', flags=r'\Deleted' ) @@ -289,9 +289,9 @@ class IMAPEmail(EmailBaseModel): ) ) - mailbox.expunge() - mailbox.close() - mailbox.logout() + server.expunge() + server.close() + server.logout() class POP3Email(EmailBaseModel):