diff src/plugins/plugin_misc_account.py @ 594:e629371a28d3

Fix pep8 support in src/plugins.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:35 +0100
parents beaf6bec2fcd
children 84a6e83157c2
line wrap: on
line diff
--- a/src/plugins/plugin_misc_account.py	Mon Jan 21 00:59:50 2013 +0100
+++ b/src/plugins/plugin_misc_account.py	Fri Jan 18 17:55:35 2013 +0100
@@ -28,14 +28,14 @@
 from twisted.mail.smtp import sendmail
 
 PLUGIN_INFO = {
-"name": "Account Plugin",
-"import_name": "MISC-ACCOUNT",
-"type": "MISC",
-"protocols": [],
-"dependencies": [],
-"main": "MiscAccount",
-"handler": "no",
-"description": _(u"""SàT account creation""")
+    "name": "Account Plugin",
+    "import_name": "MISC-ACCOUNT",
+    "type": "MISC",
+    "protocols": [],
+    "dependencies": [],
+    "main": "MiscAccount",
+    "handler": "no",
+    "description": _(u"""SàT account creation""")
 }
 
 #You need do adapt the following consts to your server
@@ -45,24 +45,24 @@
 _NEW_ACCOUNT_SERVER = "localhost"
 _NEW_ACCOUNT_DOMAIN = "example.net"
 _NEW_ACCOUNT_RESOURCE = "libervia"
-_PROSODY_PATH = None #prosody path (where prosodyctl will be executed from), or None to automaticaly find it
+_PROSODY_PATH = None  # prosody path (where prosodyctl will be executed from), or None to automaticaly find it
 _PROSODYCTL = "prosodyctl"
 
 RESERVED = ['libervia']
 
+
 class ProsodyRegisterProtocol(protocol.ProcessProtocol):
     """ Try to register an account with prosody """
 
-    def __init__(self, password, deferred = None):
+    def __init__(self, password, deferred=None):
         self.password = password
         self.deferred = deferred
         self.data = ''
 
     def connectionMade(self):
-        self.transport.write("%s\n%s" % ((self.password.encode('utf-8'),)*2))
+        self.transport.write("%s\n%s" % ((self.password.encode('utf-8'), ) * 2))
         self.transport.closeStdin()
 
-
     def outReceived(self, data):
         self.data += data
 
@@ -87,14 +87,14 @@
     def __init__(self, host):
         info(_(u"Plugin Account initialization"))
         self.host = host
-        host.bridge.addMethod("registerSatAccount", ".plugin", in_sign='sss', out_sign='', method=self._registerAccount, async = True)
+        host.bridge.addMethod("registerSatAccount", ".plugin", in_sign='sss', out_sign='', method=self._registerAccount, async=True)
         if not self._prosody_path:
             paths = which(_PROSODYCTL)
             if not paths:
-                error(_("Can't find %s") % (_PROSODYCTL,))
+                error(_("Can't find %s") % (_PROSODYCTL, ))
             else:
                 self._prosody_path = dirname(paths[0])
-                info(_('Prosody path found: %s') % (self._prosody_path,))
+                info(_('Prosody path found: %s') % (self._prosody_path, ))
 
     def _registerAccount(self, email, password, profile):
 
@@ -128,7 +128,7 @@
         #     and just change the password if the account already exists
         d = defer.Deferred()
         prosody_reg = ProsodyRegisterProtocol(password, d)
-        prosody_exe = join (self._prosody_path, _PROSODYCTL)
+        prosody_exe = join(self._prosody_path, _PROSODYCTL)
         reactor.spawnProcess(prosody_reg, prosody_exe, [prosody_exe, 'adduser', "%s@%s" % (profile, _NEW_ACCOUNT_DOMAIN)], path=self._prosody_path)
 
         d.addCallback(self._accountCreated, profile, email, password)
@@ -145,7 +145,7 @@
 
         def email_ko(ignore):
             #TODO: return error code to user
-            error ("Failed to send email to %s" % email)
+            error("Failed to send email to %s" % email)
 
         body = (u"""Welcome to Libervia, a Salut à Toi project part
 
@@ -165,7 +165,7 @@
 Any feedback welcome
 
 Cheers
-Goffi""" % { 'login': login, 'password': password, 'jid':"%s@%s" % (login, _NEW_ACCOUNT_DOMAIN) }).encode('utf-8')
+Goffi""" % {'login': login, 'password': password, 'jid': "%s@%s" % (login, _NEW_ACCOUNT_DOMAIN)}).encode('utf-8')
         msg = MIMEText(body, 'plain', 'UTF-8')
         msg['Subject'] = 'Libervia account created'
         msg['From'] = _email_from
@@ -173,10 +173,9 @@
 
         d = sendmail(_email_host, _email_from, email, msg.as_string())
         d.addCallbacks(email_ok, email_ko)
-
         #email to the administrator
 
-        body = (u"""New account created: %(login)s [%(email)s]""" % { 'login': login, 'email': email }).encode('utf-8')
+        body = (u"""New account created: %(login)s [%(email)s]""" % {'login': login, 'email': email}).encode('utf-8')
         msg = MIMEText(body, 'plain', 'UTF-8')
         msg['Subject'] = 'Libervia new account created'
         msg['From'] = _email_from