EmailClient: fix pylint warnings
This commit is contained in:
parent
c391b68dae
commit
76e28d51cd
1 changed files with 20 additions and 20 deletions
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
""" Email client """
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import smtplib
|
import smtplib
|
||||||
|
@ -14,7 +16,7 @@ from mako.template import Template as MakoTemplate
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class EmailClient(object):
|
class EmailClient(object): # pylint: disable=useless-object-inheritance,too-many-instance-attributes
|
||||||
"""
|
"""
|
||||||
Email client
|
Email client
|
||||||
|
|
||||||
|
@ -43,11 +45,11 @@ class EmailClient(object):
|
||||||
sender_name=None, sender_email=None, catch_all_addr=None, just_try=None, encoding=None, templates=None):
|
sender_name=None, sender_email=None, catch_all_addr=None, just_try=None, encoding=None, templates=None):
|
||||||
self.smtp_host = smtp_host if smtp_host else 'localhost'
|
self.smtp_host = smtp_host if smtp_host else 'localhost'
|
||||||
self.smtp_port = smtp_port if smtp_port else 25
|
self.smtp_port = smtp_port if smtp_port else 25
|
||||||
self.smtp_ssl = True if smtp_ssl else False
|
self.smtp_ssl = bool(smtp_ssl)
|
||||||
self.smtp_tls = True if smtp_tls else False
|
self.smtp_tls = bool(smtp_tls)
|
||||||
self.smtp_user = smtp_user if smtp_user else None
|
self.smtp_user = smtp_user if smtp_user else None
|
||||||
self.smtp_password = smtp_password if smtp_password else None
|
self.smtp_password = smtp_password if smtp_password else None
|
||||||
self.smtp_debug = True if smtp_debug else False
|
self.smtp_debug = bool(smtp_debug)
|
||||||
|
|
||||||
self.sender_name = sender_name if sender_name else "No reply"
|
self.sender_name = sender_name if sender_name else "No reply"
|
||||||
self.sender_email = sender_email if sender_email else "noreply@localhost"
|
self.sender_email = sender_email if sender_email else "noreply@localhost"
|
||||||
|
@ -186,7 +188,7 @@ class EmailClient(object):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
""" Run tests """
|
# Run tests
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -352,20 +354,6 @@ if __name__ == '__main__':
|
||||||
import getpass
|
import getpass
|
||||||
options.email_smtp_password = getpass.getpass('Please enter SMTP password: ')
|
options.email_smtp_password = getpass.getpass('Please enter SMTP password: ')
|
||||||
|
|
||||||
templates = dict(
|
|
||||||
test=dict(
|
|
||||||
subject="Test email",
|
|
||||||
text=(
|
|
||||||
"Just a test email sent at {sent_date}." if not options.test_mako else
|
|
||||||
MakoTemplate("Just a test email sent at ${sent_date}.")
|
|
||||||
),
|
|
||||||
html=(
|
|
||||||
"<strong>Just a test email.</stong> <small>(sent at {sent_date})</small>" if not options.test_mako else
|
|
||||||
MakoTemplate("<strong>Just a test email.</stong> <small>(sent at ${sent_date})</small>")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
logging.info('Initialize Email client')
|
logging.info('Initialize Email client')
|
||||||
email_client = EmailClient(
|
email_client = EmailClient(
|
||||||
smtp_host=options.email_smtp_host,
|
smtp_host=options.email_smtp_host,
|
||||||
|
@ -380,7 +368,19 @@ if __name__ == '__main__':
|
||||||
catch_all_addr=options.email_catch_all,
|
catch_all_addr=options.email_catch_all,
|
||||||
just_try=options.just_try,
|
just_try=options.just_try,
|
||||||
encoding=options.email_encoding,
|
encoding=options.email_encoding,
|
||||||
templates=templates
|
templates=dict(
|
||||||
|
test=dict(
|
||||||
|
subject="Test email",
|
||||||
|
text=(
|
||||||
|
"Just a test email sent at {sent_date}." if not options.test_mako else
|
||||||
|
MakoTemplate("Just a test email sent at ${sent_date}.")
|
||||||
|
),
|
||||||
|
html=(
|
||||||
|
"<strong>Just a test email.</stong> <small>(sent at {sent_date})</small>" if not options.test_mako else
|
||||||
|
MakoTemplate("<strong>Just a test email.</stong> <small>(sent at ${sent_date})</small>")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info('Send a test email to %s', options.test_to)
|
logging.info('Send a test email to %s', options.test_to)
|
||||||
|
|
Loading…
Reference in a new issue