From c7798b1a7df3dd408d6b269bc45721e2ec9680ba Mon Sep 17 00:00:00 2001 From: Jean-Philippe Caruana Date: Fri, 8 Feb 2013 17:39:25 +0100 Subject: [PATCH] no imports * and unused import --- modoboa/auth/forms.py | 11 ++++++----- modoboa/auth/lib.py | 4 ---- modoboa/auth/tests.py | 2 +- modoboa/auth/views.py | 14 +++++++------- modoboa/core/commands/deploy.py | 14 +++++++------- modoboa/core/commands/help.py | 3 ++- modoboa/core/commands/postfix_maps.py | 11 ++++++----- modoboa/tools/pfxadmin_migrate/models.py | 1 + 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/modoboa/auth/forms.py b/modoboa/auth/forms.py index d618ab436..301fc69dd 100644 --- a/modoboa/auth/forms.py +++ b/modoboa/auth/forms.py @@ -1,16 +1,17 @@ +# coding: utf-8 from django import forms from django.utils.translation import ugettext_lazy as _ class LoginForm(forms.Form): username = forms.CharField( label=_("Username"), - widget=forms.TextInput(attrs={"class" : "span3"}) - ) + widget=forms.TextInput(attrs={"class": "span3"}) + ) password = forms.CharField( label=_("Password"), - widget=forms.PasswordInput(attrs={"class" : "span3"}) - ) + widget=forms.PasswordInput(attrs={"class": "span3"}) + ) rememberme = forms.BooleanField( initial=False, required=False - ) + ) diff --git a/modoboa/auth/lib.py b/modoboa/auth/lib.py index 1a830c09b..acbc03f62 100644 --- a/modoboa/auth/lib.py +++ b/modoboa/auth/lib.py @@ -1,8 +1,4 @@ # coding: utf-8 - -import crypt, hashlib -import string -from random import Random from Crypto.Cipher import AES import base64 from modoboa.lib import parameters diff --git a/modoboa/auth/tests.py b/modoboa/auth/tests.py index 2247054b3..082b0c52d 100755 --- a/modoboa/auth/tests.py +++ b/modoboa/auth/tests.py @@ -1,3 +1,4 @@ +# coding: utf-8 """ This file demonstrates two different styles of tests (one doctest and one unittest). These will both pass when you run "manage.py test". @@ -20,4 +21,3 @@ Another way to test that 1 + 1 is equal to 2. >>> 1 + 1 == 2 True """} - diff --git a/modoboa/auth/views.py b/modoboa/auth/views.py index 417a4dc1f..69dd0fbcc 100755 --- a/modoboa/auth/views.py +++ b/modoboa/auth/views.py @@ -4,31 +4,31 @@ from django.contrib.auth import authenticate, login, logout from django.http import HttpResponse, HttpResponseRedirect from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ -from modoboa.lib import events +from modoboa.lib import events, parameters from modoboa.lib.webutils import _render_to_string from modoboa.lib.sysutils import log_warning from modoboa.admin import views as admviews from forms import LoginForm -from modoboa.auth.lib import * +from modoboa.auth.lib import encrypt def dologin(request): error = None if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): - user = authenticate(username=form.cleaned_data["username"], + user = authenticate(username=form.cleaned_data["username"], password=form.cleaned_data["password"]) if user and user.is_active: if not form.cleaned_data["rememberme"]: request.session.set_expiry(0) - login(request, user) + login(request, user) if request.user.id != 1: request.session["password"] = encrypt(request.POST["password"]) request.session["django_language"] = \ parameters.get_user(request.user, "LANG", app="general") - events.raiseEvent("UserLogin", request, + events.raiseEvent("UserLogin", request, form.cleaned_data["username"], form.cleaned_data["password"]) @@ -38,7 +38,7 @@ def dologin(request): return HttpResponseRedirect(next) error = _("Your username and password didn't match. Please try again.") log_warning("Failed connection attempt from %(addr)s as user %(user)s" \ - % {"addr" : request.META["REMOTE_ADDR"], + % {"addr" : request.META["REMOTE_ADDR"], "user" : form.cleaned_data["username"]}) next = request.POST.get("next", None) @@ -49,7 +49,7 @@ def dologin(request): httpcode = 200 return HttpResponse(_render_to_string(request, "registration/login.html", { - "form" : form, "error" : error, "next" : next, + "form" : form, "error" : error, "next" : next, "annoucements" : events.raiseQueryEvent("GetAnnouncement", "loginpage") }), status=httpcode) diff --git a/modoboa/core/commands/deploy.py b/modoboa/core/commands/deploy.py index 8bd81eda8..63f857813 100644 --- a/modoboa/core/commands/deploy.py +++ b/modoboa/core/commands/deploy.py @@ -1,3 +1,4 @@ +# coding: utf-8 import sys import os import shutil @@ -53,7 +54,7 @@ class DeployCommand(Command): output = None if p.returncode: if output: - print >>sys.stderr, "\n".join(filter(lambda l: l != None, output)) + print >>sys.stderr, "\n".join(filter(lambda l: l is not None, output)) print >>sys.stderr, "%s failed, check your configuration" % cmd def ask_db_info(self, name='default'): @@ -65,8 +66,7 @@ class DeployCommand(Command): :param name: the connection name """ print "Configuring database connection: %s" % name - info = {'conn_name' : name} - info['dbtype'] = raw_input('Database type (mysql or postgres): ') + info = {'conn_name': name, 'dbtype': raw_input('Database type (mysql or postgres): ')} if info['dbtype'] not in ['mysql', 'postgres']: info['dbtype'] = 'mysql' if info['dbtype'] == 'postgres': @@ -78,7 +78,7 @@ class DeployCommand(Command): info['username'] = raw_input('Username: ') info['password'] = getpass.getpass('Password: ') return info - + def handle(self, parsed_args): management.call_command('startproject', parsed_args.name, verbosity=False) if os.path.exists("%(name)s/%(name)s" % {'name' : parsed_args.name}): @@ -90,7 +90,7 @@ class DeployCommand(Command): path = parsed_args.name sys.path.append(".") django14 = False - + t = Template(dbconn_tpl) default_conn = t.render(Context(self.ask_db_info())) amavis_conn = t.render(Context(self.ask_db_info('amavis'))) if parsed_args.with_amavis \ @@ -107,10 +107,10 @@ class DeployCommand(Command): fp.close() shutil.copyfile("%s/urls.py" % self._templates_dir, "%s/urls.py" % path) os.mkdir("%s/media" % path) - + if parsed_args.syncdb: self._exec_django_command("syncdb", parsed_args.name, '--migrate', '--noinput') self._exec_django_command("loaddata", parsed_args.name, 'initial_users.json') - + if parsed_args.collectstatic: self._exec_django_command("collectstatic", parsed_args.name, '--noinput') diff --git a/modoboa/core/commands/help.py b/modoboa/core/commands/help.py index bbf6f282c..882ff75f6 100644 --- a/modoboa/core/commands/help.py +++ b/modoboa/core/commands/help.py @@ -1,3 +1,4 @@ +# coding: utf-8 import sys from modoboa.core.management import Command @@ -8,7 +9,7 @@ class HelpCommand(Command): super(HelpCommand, self).__init__(*args, **kwargs) self._parser.add_argument('name', type=str, help='A command name') - + def handle(self, parsed_args): if not self._commands.has_key(parsed_args.name): print >>sys.stderr, "Unknown command: %s" % parsed_args.name diff --git a/modoboa/core/commands/postfix_maps.py b/modoboa/core/commands/postfix_maps.py index 8f0aef9f6..f6eaf1b16 100644 --- a/modoboa/core/commands/postfix_maps.py +++ b/modoboa/core/commands/postfix_maps.py @@ -1,3 +1,4 @@ +# coding: utf-8 import getpass import inspect import os @@ -84,14 +85,14 @@ class PostfixMapsCommand(Command): help='Used database type') self._parser.add_argument('--dbhost', type=str, default='127.0.0.1', help='Database host address') - self._parser.add_argument('--categories', type=str, nargs='*', default=['std'], + self._parser.add_argument('--categories', type=str, nargs='*', default=['std'], help='Map file categories to generate (choices: std, autoreply)') - + def handle(self, parsed_args): dbname = raw_input('Database name: ') dbuser = raw_input('Username: ') dbpass = getpass.getpass('Password: ') - + try: os.mkdir(parsed_args.destdir) except OSError: @@ -102,6 +103,6 @@ class PostfixMapsCommand(Command): continue if not v.category in parsed_args.categories: continue - v().render(parsed_args.destdir, parsed_args.dbtype, - dbname=dbname, dbuser=dbuser, dbpassword=dbpass, + v().render(parsed_args.destdir, parsed_args.dbtype, + dbname=dbname, dbuser=dbuser, dbpassword=dbpass, dbhost=parsed_args.dbhost) diff --git a/modoboa/tools/pfxadmin_migrate/models.py b/modoboa/tools/pfxadmin_migrate/models.py index 89625599a..cbb86ac92 100755 --- a/modoboa/tools/pfxadmin_migrate/models.py +++ b/modoboa/tools/pfxadmin_migrate/models.py @@ -1,3 +1,4 @@ +# coding: utf-8 # This is an auto-generated Django model module. # You'll have to do the following manually to clean this up: # * Rearrange models' order