diff --git a/modoboa/core/commands/deploy.py b/modoboa/core/commands/deploy.py index 794bbedfa..1fa808f64 100644 --- a/modoboa/core/commands/deploy.py +++ b/modoboa/core/commands/deploy.py @@ -143,6 +143,16 @@ class DeployCommand(Command): info['PASSWORD'] = getpass.getpass('Password: ') return info + def _get_extension_list(self): + """Ask the API to get the list of all extensions. + + We hardcode the API url here to avoid a loading of + django's settings since they are not available yet... + """ + url = "http://api.modoboa.org/" + official_exts = ModoAPIClient(url).list_extensions() + return [extension["name"] for extension in official_exts] + def install_extensions(self, extensions): """Install one or more extensions. @@ -150,13 +160,6 @@ class DeployCommand(Command): include in the final configuration. """ - if "all" in extensions: - # We hardcode the API url here to avoid a loading of - # django's settings since they are not available yet... - url = "http://api.modoboa.org/" - official_exts = ModoAPIClient(url).list_extensions() - extensions = [extension["name"] for extension in official_exts] - pip_args = ["install"] + extensions pip.main(pip_args) extra_settings = [] @@ -206,8 +209,11 @@ class DeployCommand(Command): allowed_host = "localhost" extra_settings = [] - if parsed_args.dont_install_extensions and parsed_args.extensions: - extra_settings = self.install_extensions(parsed_args.extensions) + extensions = parsed_args.extensions + if "all" in extensions: + extensions = self._get_extension_list() + if not parsed_args.dont_install_extensions and extensions: + extra_settings = self.install_extensions(extensions) bower_components_dir = os.path.realpath( os.path.join(os.path.dirname(__file__), "../../bower_components") @@ -224,7 +230,7 @@ class DeployCommand(Command): 'timezone': parsed_args.timezone, 'bower_components_dir': bower_components_dir, 'devmode': parsed_args.devel, - 'extensions': parsed_args.extensions, + 'extensions': extensions, 'extra_settings': extra_settings } )