Rename variable mailbox to server for clarity
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -256,15 +256,15 @@ class IMAPEmail(EmailBaseModel):
|
|||||||
logger.debug('ssl: %s', self.ssl)
|
logger.debug('ssl: %s', self.ssl)
|
||||||
|
|
||||||
if 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:
|
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)
|
||||||
mailbox.select(mailbox=self.mailbox)
|
server.select(mailbox=self.mailbox)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
status, data = mailbox.uid(
|
status, data = server.uid(
|
||||||
'SEARCH', None, *self.search_criteria.strip().split()
|
'SEARCH', None, *self.search_criteria.strip().split()
|
||||||
)
|
)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
@@ -280,7 +280,7 @@ class IMAPEmail(EmailBaseModel):
|
|||||||
|
|
||||||
for uid in uids:
|
for uid in uids:
|
||||||
logger.debug('message uid: %s', uid)
|
logger.debug('message uid: %s', uid)
|
||||||
status, data = mailbox.uid('FETCH', uid, '(RFC822)')
|
status, data = server.uid('FETCH', uid, '(RFC822)')
|
||||||
EmailBaseModel.process_message(
|
EmailBaseModel.process_message(
|
||||||
source=self, message_text=data[0][1]
|
source=self, message_text=data[0][1]
|
||||||
)
|
)
|
||||||
@@ -291,7 +291,7 @@ class IMAPEmail(EmailBaseModel):
|
|||||||
try:
|
try:
|
||||||
args = [uid]
|
args = [uid]
|
||||||
args.extend(command.strip().split(' '))
|
args.extend(command.strip().split(' '))
|
||||||
mailbox.uid('STORE', *args)
|
server.uid('STORE', *args)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
raise SourceException(
|
raise SourceException(
|
||||||
'Error executing IMAP store command "{}" '
|
'Error executing IMAP store command "{}" '
|
||||||
@@ -302,7 +302,7 @@ class IMAPEmail(EmailBaseModel):
|
|||||||
|
|
||||||
if self.mailbox_destination:
|
if self.mailbox_destination:
|
||||||
try:
|
try:
|
||||||
mailbox.uid(
|
server.uid(
|
||||||
'COPY', uid, self.mailbox_destination
|
'COPY', uid, self.mailbox_destination
|
||||||
)
|
)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
@@ -314,10 +314,10 @@ class IMAPEmail(EmailBaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if self.execute_expunge:
|
if self.execute_expunge:
|
||||||
mailbox.expunge()
|
server.expunge()
|
||||||
|
|
||||||
mailbox.close()
|
server.close()
|
||||||
mailbox.logout()
|
server.logout()
|
||||||
|
|
||||||
|
|
||||||
class POP3Email(EmailBaseModel):
|
class POP3Email(EmailBaseModel):
|
||||||
@@ -339,16 +339,16 @@ class POP3Email(EmailBaseModel):
|
|||||||
logger.debug('ssl: %s', self.ssl)
|
logger.debug('ssl: %s', self.ssl)
|
||||||
|
|
||||||
if self.ssl:
|
if self.ssl:
|
||||||
mailbox = poplib.POP3_SSL(host=self.host, port=self.port)
|
server = poplib.POP3_SSL(host=self.host, port=self.port)
|
||||||
else:
|
else:
|
||||||
mailbox = poplib.POP3(
|
server = poplib.POP3(
|
||||||
host=self.host, port=self.port, timeout=self.timeout
|
host=self.host, port=self.port, timeout=self.timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
mailbox.getwelcome()
|
server.getwelcome()
|
||||||
mailbox.user(self.username)
|
server.user(self.username)
|
||||||
mailbox.pass_(self.password)
|
server.pass_(self.password)
|
||||||
messages_info = mailbox.list()
|
messages_info = server.list()
|
||||||
|
|
||||||
logger.debug(msg='messages_info:')
|
logger.debug(msg='messages_info:')
|
||||||
logger.debug(msg=messages_info)
|
logger.debug(msg=messages_info)
|
||||||
@@ -359,12 +359,12 @@ class POP3Email(EmailBaseModel):
|
|||||||
logger.debug('message_number: %s', message_number)
|
logger.debug('message_number: %s', message_number)
|
||||||
logger.debug('message_size: %s', message_size)
|
logger.debug('message_size: %s', message_size)
|
||||||
|
|
||||||
complete_message = '\n'.join(mailbox.retr(message_number)[1])
|
complete_message = '\n'.join(server.retr(message_number)[1])
|
||||||
|
|
||||||
EmailBaseModel.process_message(
|
EmailBaseModel.process_message(
|
||||||
source=self, message_text=complete_message
|
source=self, message_text=complete_message
|
||||||
)
|
)
|
||||||
if not test:
|
if not test:
|
||||||
mailbox.dele(which=message_number)
|
server.dele(which=message_number)
|
||||||
|
|
||||||
mailbox.quit()
|
server.quit()
|
||||||
|
|||||||
Reference in New Issue
Block a user