summaryrefslogtreecommitdiffstats
path: root/askbot/deployment
diff options
context:
space:
mode:
authorAdolfo Fitoria <adolfo.fitoria@gmail.com>2011-09-15 10:13:45 -0300
committerAdolfo Fitoria <adolfo.fitoria@gmail.com>2011-09-15 10:13:45 -0300
commite2c285f8208624a51c969f92e055808fb64f93a4 (patch)
tree6ee7e65bf43ab4a1db58c91e838dd2bafbf7bdca /askbot/deployment
parent84e573c204b24fe06d4edba03bf4b4696da3339a (diff)
downloadaskbot-e2c285f8208624a51c969f92e055808fb64f93a4.tar.gz
askbot-e2c285f8208624a51c969f92e055808fb64f93a4.tar.bz2
askbot-e2c285f8208624a51c969f92e055808fb64f93a4.zip
almost done with new setup command options
Diffstat (limited to 'askbot/deployment')
-rw-r--r--askbot/deployment/__init__.py14
-rw-r--r--askbot/deployment/path_utils.py20
-rw-r--r--askbot/deployment/template_loader.py2
3 files changed, 31 insertions, 5 deletions
diff --git a/askbot/deployment/__init__.py b/askbot/deployment/__init__.py
index bfddeccc..10de3c25 100644
--- a/askbot/deployment/__init__.py
+++ b/askbot/deployment/__init__.py
@@ -162,15 +162,25 @@ def askbot_setup():
def deploy_askbot(directory, create_new, options):
'''function that copies the templates'''
help_file = path_utils.get_path_to_help_file()
+ context = {'database_name': options.database_name,
+ 'database_password': options.database_password,
+ 'database_user': options.database_user
+ }
+ for key in context.keys():
+ if context[key] == None:
+ input_message = 'Please enter a value for %s:' % (key.replace('_', ' '))
+ new_value = raw_input(input_message)
+ context[key] = new_value
+
if create_new:
path_utils.create_path(directory)
path_utils.deploy_into(directory, new_project = True,
- verbosity = options.verbosity)
+ verbosity = options.verbosity, context = context)
if options.verbosity >= 1:
print messages.HOW_TO_DEPLOY_NEW % {'help_file': help_file}
else:
path_utils.deploy_into(directory, new_project = False,
- verbosity = options.verbosity)
+ verbosity = options.verbosity, context = context)
if options.verbosity >= 1:
print messages.HOW_TO_ADD_ASKBOT_TO_DJANGO % {'help_file': help_file}
diff --git a/askbot/deployment/path_utils.py b/askbot/deployment/path_utils.py
index 7499e2c9..95f24735 100644
--- a/askbot/deployment/path_utils.py
+++ b/askbot/deployment/path_utils.py
@@ -11,6 +11,7 @@ import re
import glob
import shutil
import imp
+from askbot.deployment.template_loader import SettingsTemplate
def split_at_break_point(directory):
"""splits directory path into two pieces
@@ -123,12 +124,12 @@ def get_path_to_help_file():
"""returns path to the main plain text help file"""
return os.path.join(SOURCE_DIR, 'doc', 'INSTALL')
-def deploy_into(directory, new_project = None, verbosity=1):
+def deploy_into(directory, new_project = None, verbosity=1, context=None):
"""will copy necessary files into the directory
"""
assert(new_project is not None)
if new_project:
- copy_files = ('__init__.py', 'settings.py', 'manage.py', 'urls.py')
+ copy_files = ('__init__.py', 'manage.py', 'urls.py')
blank_files = ('__init__.py', 'manage.py')
if verbosity >=1:
print 'Copying files: '
@@ -151,6 +152,21 @@ def deploy_into(directory, new_project = None, verbosity=1):
create_path(log_dir)
touch(os.path.join(log_dir, 'askbot.log'))
+ #creating settings file from template
+ if verbosity>=1:
+ print "Creating settings file"
+ settings_contents = SettingsTemplate(context).render()
+ settings_path = os.path.join(directory, 'settings.py')
+ if os.path.exists(settings_path):
+ if verbosity>=1:
+ print "* you already have a settings file please merge the contents"
+ else:
+ settings_file = open(settings_path, 'w+')
+ settings_file.write(settings_contents)
+ settings_file.close()
+ if verbosity>=1:
+ print "settings file created"
+
if verbosity >=1:
print ''
app_dir = os.path.join(directory, 'askbot')
diff --git a/askbot/deployment/template_loader.py b/askbot/deployment/template_loader.py
index b7820ed0..fe7c11e6 100644
--- a/askbot/deployment/template_loader.py
+++ b/askbot/deployment/template_loader.py
@@ -1,7 +1,7 @@
import os
import pystache
-from path_utils import SOURCE_DIR
+SOURCE_DIR = os.path.dirname(os.path.dirname(__file__))
class SettingsTemplate(pystache.View):
'''Class for settings'''