core: use of the new core.log module:
/!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
This commit is contained in:
parent
dc5c042fe7
commit
501bc92528
1 changed files with 707 additions and 941 deletions
|
|
@ -18,10 +18,9 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sat.core.i18n import _
|
||||
from logging import debug, info, error
|
||||
import warnings
|
||||
from twisted.internet import protocol, defer
|
||||
from twisted.words.protocols.jabber import error as jab_error
|
||||
from sat.core.log import getLogger
|
||||
log = getLogger(__name__)
|
||||
from twisted.internet import defer
|
||||
from twisted.cred import portal, checkers, credentials
|
||||
from twisted.cred import error as cred_error
|
||||
from twisted.mail import smtp
|
||||
|
|
@ -29,7 +28,6 @@ from twisted.python import failure
|
|||
from email.parser import Parser
|
||||
from email.utils import parseaddr
|
||||
from twisted.mail.imap4 import LOGINCredentials, PLAINCredentials
|
||||
import os
|
||||
from twisted.internet import reactor
|
||||
import sys
|
||||
|
||||
|
|
@ -60,14 +58,14 @@ class SMTP_server(object):
|
|||
"""
|
||||
|
||||
def __init__(self, host):
|
||||
info(_("Plugin SMTP Server initialization"))
|
||||
log.info(_("Plugin SMTP Server initialization"))
|
||||
self.host = host
|
||||
|
||||
#parameters
|
||||
host.memory.updateParams(self.params)
|
||||
|
||||
port = int(self.host.memory.getParamA("SMTP Port", "Mail Server"))
|
||||
info(_("Launching SMTP server on port %d"), port)
|
||||
log.info(_("Launching SMTP server on port %d") % port)
|
||||
|
||||
self.server_factory = SmtpServerFactory(self.host)
|
||||
reactor.listenTCP(port, self.server_factory)
|
||||
|
|
@ -93,7 +91,7 @@ class SatSmtpMessage(object):
|
|||
subject=mail['subject'].decode('utf-8', 'replace'), mess_type='normal', profile_key=self.profile)
|
||||
except:
|
||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
error(_("Can't send message: %s") % exc_value) # The email is invalid or incorreclty parsed
|
||||
log.error(_("Can't send message: %s") % exc_value) # The email is invalid or incorreclty parsed
|
||||
return defer.fail()
|
||||
self.message = None
|
||||
return defer.succeed(None)
|
||||
|
|
@ -152,7 +150,7 @@ class SmtpRealm(object):
|
|||
self.host = host
|
||||
|
||||
def requestAvatar(self, avatarID, mind, *interfaces):
|
||||
debug('requestAvatar')
|
||||
log.debug('requestAvatar')
|
||||
profile = avatarID.decode('utf-8')
|
||||
if smtp.IMessageDelivery not in interfaces:
|
||||
raise NotImplementedError
|
||||
|
|
@ -198,11 +196,11 @@ class SmtpServerFactory(smtp.SMTPFactory):
|
|||
smtp.SMTPFactory.__init__(self, _portal)
|
||||
|
||||
def startedConnecting(self, connector):
|
||||
debug(_("SMTP server connection started"))
|
||||
log.debug(_("SMTP server connection started"))
|
||||
smtp.SMTPFactory.startedConnecting(self, connector)
|
||||
|
||||
def clientConnectionLost(self, connector, reason):
|
||||
debug(_("SMTP server connection lost (reason: %s)"), reason)
|
||||
log.debug(_("SMTP server connection lost (reason: %s)"), reason)
|
||||
smtp.SMTPFactory.clientConnectionLost(self, connector, reason)
|
||||
|
||||
def buildProtocol(self, addr):
|
||||
|
|
|
|||
Loading…
Reference in a new issue