From 3297b88d4f4277ff1e7006472fa0bac9f8cb7f73 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 10 Feb 2017 15:39:37 +0100 Subject: [PATCH] Fixed deploy command. see #1024 --- modoboa/admin/urls.py | 1 + modoboa/core/commands/__init__.py | 21 +++++++++++++-------- modoboa/core/commands/deploy.py | 1 - 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/modoboa/admin/urls.py b/modoboa/admin/urls.py index 9ef0bde9e..1934ced58 100644 --- a/modoboa/admin/urls.py +++ b/modoboa/admin/urls.py @@ -1,3 +1,4 @@ +# pylint: disable=invalid-name, protected-access """Admin urls.""" from django.conf.urls import url diff --git a/modoboa/core/commands/__init__.py b/modoboa/core/commands/__init__.py index 6ab7b00aa..f767830b3 100644 --- a/modoboa/core/commands/__init__.py +++ b/modoboa/core/commands/__init__.py @@ -9,8 +9,7 @@ from django.template import Context, Template class Command(object): - - """Base command class + """Base command class. A valid administrative command must inherit from this class. """ @@ -22,7 +21,12 @@ class Command(object): self._parser = argparse.ArgumentParser() self._verbose = verbose if not settings.configured: - settings.configure() + settings.configure( + TEMPLATES=[{ + "BACKEND": ( + "django.template.backends.django.DjangoTemplates") + }] + ) self._templates_dir = "%s/templates" % os.path.dirname(__file__) def _render_template(self, tplfile, env): @@ -52,18 +56,19 @@ def scan_for_commands(dirname=""): path = os.path.join(os.path.dirname(__file__), dirname) result = {} for f in os.listdir(path): - if f in ['.', '..', '__init__.py']: + if f in [".", "..", "__init__.py"]: continue - if not f.endswith('.py'): + if not f.endswith(".py"): continue if os.path.isfile(f): continue - cmdname = f.replace('.py', '') + cmdname = f.replace(".py", "") cmdmod = __import__("modoboa.core.commands", globals(), locals(), [cmdname]) cmdmod = getattr(cmdmod, cmdname) - if '_' in cmdname: - cmdclassname = ''.join([s.capitalize() for s in cmdname.split('_')]) + if "_" in cmdname: + cmdclassname = "".join( + [s.capitalize() for s in cmdname.split("_")]) else: cmdclassname = cmdname.capitalize() try: diff --git a/modoboa/core/commands/deploy.py b/modoboa/core/commands/deploy.py index 28c55936a..7cfa145b9 100644 --- a/modoboa/core/commands/deploy.py +++ b/modoboa/core/commands/deploy.py @@ -17,7 +17,6 @@ except ImportError: import django from django.core import management from django.template import Context, Template - import dj_database_url from modoboa.core.commands import Command