mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-06-20 09:37:48 +02:00
Merge pull request #1265 from emmanuel-ferdman/main
Migrate to modern Python logger API
This commit is contained in:
commit
73b19cd423
@ -168,11 +168,13 @@ def pop3_sync(q, logger, server):
|
|||||||
message=full_message, queue=q, logger=logger
|
message=full_message, queue=q, logger=logger
|
||||||
)
|
)
|
||||||
except IgnoreTicketException:
|
except IgnoreTicketException:
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Message %s was ignored and will be left on POP3 server" % msgNum
|
"Message %s was ignored and will be left on POP3 server" % msgNum
|
||||||
)
|
)
|
||||||
except DeleteIgnoredTicketException:
|
except DeleteIgnoredTicketException:
|
||||||
logger.warn("Message %s was ignored and deleted from POP3 server" % msgNum)
|
logger.warning(
|
||||||
|
"Message %s was ignored and deleted from POP3 server" % msgNum
|
||||||
|
)
|
||||||
server.dele(msgNum)
|
server.dele(msgNum)
|
||||||
else:
|
else:
|
||||||
if ticket:
|
if ticket:
|
||||||
@ -182,7 +184,7 @@ def pop3_sync(q, logger, server):
|
|||||||
% msgNum
|
% msgNum
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Message %s was not successfully processed, and will be left on POP3 server"
|
"Message %s was not successfully processed, and will be left on POP3 server"
|
||||||
% msgNum
|
% msgNum
|
||||||
)
|
)
|
||||||
@ -232,12 +234,12 @@ def imap_sync(q, logger, server):
|
|||||||
message=full_message, queue=q, logger=logger
|
message=full_message, queue=q, logger=logger
|
||||||
)
|
)
|
||||||
except IgnoreTicketException:
|
except IgnoreTicketException:
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Message %s was ignored and will be left on IMAP server" % num
|
"Message %s was ignored and will be left on IMAP server" % num
|
||||||
)
|
)
|
||||||
except DeleteIgnoredTicketException:
|
except DeleteIgnoredTicketException:
|
||||||
server.store(num, "+FLAGS", "\\Deleted")
|
server.store(num, "+FLAGS", "\\Deleted")
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Message %s was ignored and deleted from IMAP server" % num
|
"Message %s was ignored and deleted from IMAP server" % num
|
||||||
)
|
)
|
||||||
except TypeError as te:
|
except TypeError as te:
|
||||||
@ -253,7 +255,7 @@ def imap_sync(q, logger, server):
|
|||||||
% num
|
% num
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Message %s was not successfully processed, and will be left on IMAP server"
|
"Message %s was not successfully processed, and will be left on IMAP server"
|
||||||
% num
|
% num
|
||||||
)
|
)
|
||||||
@ -331,12 +333,12 @@ def imap_oauth_sync(q, logger, server):
|
|||||||
)
|
)
|
||||||
|
|
||||||
except IgnoreTicketException as itex:
|
except IgnoreTicketException as itex:
|
||||||
logger.warn(f"Message {num} was ignored. {itex}")
|
logger.warning(f"Message {num} was ignored. {itex}")
|
||||||
|
|
||||||
except DeleteIgnoredTicketException:
|
except DeleteIgnoredTicketException:
|
||||||
server.store(num, "+FLAGS", "\\Deleted")
|
server.store(num, "+FLAGS", "\\Deleted")
|
||||||
server.expunge()
|
server.expunge()
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Message %s was ignored and deleted from IMAP server" % num
|
"Message %s was ignored and deleted from IMAP server" % num
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -355,7 +357,7 @@ def imap_oauth_sync(q, logger, server):
|
|||||||
% num
|
% num
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Message %s was not successfully processed, and will be left on IMAP server"
|
"Message %s was not successfully processed, and will be left on IMAP server"
|
||||||
% num
|
% num
|
||||||
)
|
)
|
||||||
@ -466,12 +468,14 @@ def process_queue(q, logger):
|
|||||||
message=full_message, queue=q, logger=logger
|
message=full_message, queue=q, logger=logger
|
||||||
)
|
)
|
||||||
except IgnoreTicketException:
|
except IgnoreTicketException:
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Message %d was ignored and will be left in local directory", i
|
"Message %d was ignored and will be left in local directory", i
|
||||||
)
|
)
|
||||||
except DeleteIgnoredTicketException:
|
except DeleteIgnoredTicketException:
|
||||||
os.unlink(m)
|
os.unlink(m)
|
||||||
logger.warn("Message %d was ignored and deleted local directory", i)
|
logger.warning(
|
||||||
|
"Message %d was ignored and deleted local directory", i
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if ticket:
|
if ticket:
|
||||||
logger.info(
|
logger.info(
|
||||||
@ -486,7 +490,7 @@ def process_queue(q, logger):
|
|||||||
else:
|
else:
|
||||||
logger.info("Successfully deleted message %d.", i)
|
logger.info("Successfully deleted message %d.", i)
|
||||||
else:
|
else:
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Message %d was not successfully processed, and will be left in local directory",
|
"Message %d was not successfully processed, and will be left in local directory",
|
||||||
i,
|
i,
|
||||||
)
|
)
|
||||||
@ -857,7 +861,7 @@ def extract_email_message_content(
|
|||||||
"""
|
"""
|
||||||
Uses the get_body() method of the email package to extract the email message content.
|
Uses the get_body() method of the email package to extract the email message content.
|
||||||
If there is an HTML version of the email message content then it is stored as an attachment.
|
If there is an HTML version of the email message content then it is stored as an attachment.
|
||||||
If there is a plain text part then that is used for storing the email content aginst the ticket.
|
If there is a plain text part then that is used for storing the email content against the ticket.
|
||||||
Otherwise if there is just an HTML part then the HTML is parsed to extract a simple text message.
|
Otherwise if there is just an HTML part then the HTML is parsed to extract a simple text message.
|
||||||
There is special handling for the case when a multipart/related part holds the message content when
|
There is special handling for the case when a multipart/related part holds the message content when
|
||||||
there are multiple attachments to the email.
|
there are multiple attachments to the email.
|
||||||
@ -999,7 +1003,7 @@ def extract_attachments(
|
|||||||
if "multipart/related" == content_type:
|
if "multipart/related" == content_type:
|
||||||
if content_parts_excluded:
|
if content_parts_excluded:
|
||||||
# This should really never happen in a properly constructed email message but...
|
# This should really never happen in a properly constructed email message but...
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"WARNING! Content type MIME parts have been excluded but a multipart/related has been encountered.\
|
"WARNING! Content type MIME parts have been excluded but a multipart/related has been encountered.\
|
||||||
There may be missing information in attachments."
|
There may be missing information in attachments."
|
||||||
)
|
)
|
||||||
@ -1025,7 +1029,7 @@ def extract_attachments(
|
|||||||
counter, content_parts_excluded = extract_attachments(
|
counter, content_parts_excluded = extract_attachments(
|
||||||
part, files, logger, counter, content_parts_excluded
|
part, files, logger, counter, content_parts_excluded
|
||||||
)
|
)
|
||||||
# If we have found 1 or more content parts then flag that the content parts have been ommitted
|
# If we have found 1 or more content parts then flag that the content parts have been omitted
|
||||||
# to ensure that other text/* parts are attached
|
# to ensure that other text/* parts are attached
|
||||||
if content_part_detected:
|
if content_part_detected:
|
||||||
content_parts_excluded = True
|
content_parts_excluded = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user