diff src/plugins/plugin_misc_smtp.py @ 993:301b342c697a

core: use of the new core.log module: /!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
author Goffi <goffi@goffi.org>
date Sat, 19 Apr 2014 19:19:19 +0200
parents bfabeedbf32e
children e90125d07072
line wrap: on
line diff
--- a/src/plugins/plugin_misc_smtp.py	Sat Apr 19 16:48:26 2014 +0200
+++ b/src/plugins/plugin_misc_smtp.py	Sat Apr 19 19:19:19 2014 +0200
@@ -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 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 @@
     """
 
     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 @@
                                   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 @@
         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 @@
         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):