From 1de3b24ed9844c4b39ad9d78f87cb1e1f2cd3985 Mon Sep 17 00:00:00 2001 From: Gabriel Hurley Date: Mon, 21 May 2012 15:42:26 -0700 Subject: [PATCH] Allow setup.py bdist to complete happily. Fixes bug 1002551. Change-Id: Ied984f020a6ae97375824fbc1297739db032ed0b --- .../{dashboard.py => dashboard.py.tmpl} | 0 .../conf/panel_template/{panel.py => panel.py.tmpl} | 0 .../conf/panel_template/{tests.py => tests.py.tmpl} | 0 horizon/management/commands/startdash.py | 12 +++++++++++- horizon/management/commands/startpanel.py | 11 ++++++++++- 5 files changed, 21 insertions(+), 2 deletions(-) rename horizon/conf/dash_template/{dashboard.py => dashboard.py.tmpl} (100%) rename horizon/conf/panel_template/{panel.py => panel.py.tmpl} (100%) rename horizon/conf/panel_template/{tests.py => tests.py.tmpl} (100%) diff --git a/horizon/conf/dash_template/dashboard.py b/horizon/conf/dash_template/dashboard.py.tmpl similarity index 100% rename from horizon/conf/dash_template/dashboard.py rename to horizon/conf/dash_template/dashboard.py.tmpl diff --git a/horizon/conf/panel_template/panel.py b/horizon/conf/panel_template/panel.py.tmpl similarity index 100% rename from horizon/conf/panel_template/panel.py rename to horizon/conf/panel_template/panel.py.tmpl diff --git a/horizon/conf/panel_template/tests.py b/horizon/conf/panel_template/tests.py.tmpl similarity index 100% rename from horizon/conf/panel_template/tests.py rename to horizon/conf/panel_template/tests.py.tmpl diff --git a/horizon/management/commands/startdash.py b/horizon/management/commands/startdash.py index e4f51f0ed..9ffdd20e4 100644 --- a/horizon/management/commands/startdash.py +++ b/horizon/management/commands/startdash.py @@ -1,3 +1,4 @@ +import glob from optparse import make_option import os @@ -34,7 +35,7 @@ class Command(TemplateCommand): options["template"] = self.template # We have html templates as well, so make sure those are included. - options["extensions"].extend(["html", "js", "css"]) + options["extensions"].extend(["tmpl", "html", "js", "css"]) # Check that the app_name cannot be imported. try: @@ -47,3 +48,12 @@ class Command(TemplateCommand): "name. Please try another name." % dash_name) super(Command, self).handle('dash', dash_name, **options) + + target = options.pop("target", None) + if not target: + target = os.path.join(os.curdir, dash_name) + + # Rename our python template files. + file_names = glob.glob(os.path.join(target, "*.py.tmpl")) + for filename in file_names: + os.rename(filename, filename[:-5]) diff --git a/horizon/management/commands/startpanel.py b/horizon/management/commands/startpanel.py index c320e2f65..ed11f8991 100644 --- a/horizon/management/commands/startpanel.py +++ b/horizon/management/commands/startpanel.py @@ -1,3 +1,4 @@ +import glob from optparse import make_option import os @@ -74,7 +75,7 @@ class Command(TemplateCommand): options["template"] = self.template # We have html templates as well, so make sure those are included. - options["extensions"].extend(["html"]) + options["extensions"].extend(["tmpl", "html"]) # Check that the app_name cannot be imported. try: @@ -87,3 +88,11 @@ class Command(TemplateCommand): "name. Please try another name." % panel_name) super(Command, self).handle('panel', panel_name, target, **options) + + if not target: + target = os.path.join(os.curdir, panel_name) + + # Rename our python template files. + file_names = glob.glob(os.path.join(target, "*.py.tmpl")) + for filename in file_names: + os.rename(filename, filename[:-5])