diff --git a/modoboa/core/commands/__init__.py b/modoboa/core/commands/__init__.py index b1b2cf62e..6ab7b00aa 100644 --- a/modoboa/core/commands/__init__.py +++ b/modoboa/core/commands/__init__.py @@ -14,9 +14,10 @@ class Command(object): A valid administrative command must inherit from this class. """ + help = "No help available." - def __init__(self, commands, verbose=False, **kwargs): + def __init__(self, commands, verbose=False): self._commands = commands self._parser = argparse.ArgumentParser() self._verbose = verbose @@ -25,10 +26,10 @@ class Command(object): self._templates_dir = "%s/templates" % os.path.dirname(__file__) def _render_template(self, tplfile, env): - fp = open(tplfile) - t = Template(fp.read()) - fp.close() - return t.render(Context(env)) + """Render an HTML template.""" + with open(tplfile) as fp: + tpl = Template(fp.read()) + return tpl.render(Context(env)) def run(self, cmdline): args = self._parser.parse_args(cmdline) diff --git a/modoboa/core/commands/deploy.py b/modoboa/core/commands/deploy.py index ae750d3f5..8d965cba6 100644 --- a/modoboa/core/commands/deploy.py +++ b/modoboa/core/commands/deploy.py @@ -172,6 +172,7 @@ class DeployCommand(Command): return extra_settings def handle(self, parsed_args): + import pdb django.setup() management.call_command( 'startproject', parsed_args.name, verbosity=False @@ -206,15 +207,16 @@ class DeployCommand(Command): ) if not allowed_host: allowed_host = "localhost" - extra_settings = [] extensions = parsed_args.extensions - if "all" in extensions: - extensions = self._get_extension_list() - extensions = [(extension, extension.replace("-", "_")) - for extension in extensions] - if not parsed_args.dont_install_extensions and extensions: - extra_settings = self.install_extensions(extensions) + if extensions: + if "all" in extensions: + extensions = self._get_extension_list() + extensions = [(extension, extension.replace("-", "_")) + for extension in extensions] + if not parsed_args.dont_install_extensions: + extra_settings = self.install_extensions(extensions) + extensions = [extension[1] for extension in extensions] bower_components_dir = os.path.realpath( os.path.join(os.path.dirname(__file__), "../../bower_components") @@ -231,7 +233,7 @@ class DeployCommand(Command): 'timezone': parsed_args.timezone, 'bower_components_dir': bower_components_dir, 'devmode': parsed_args.devel, - 'extensions': [extension[1] for extension in extensions], + 'extensions': extensions, 'extra_settings': extra_settings } )