diff options
Diffstat (limited to 'master/setup-master.py')
-rwxr-xr-x | master/setup-master.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/master/setup-master.py b/master/setup-master.py new file mode 100755 index 0000000..448933d --- /dev/null +++ b/master/setup-master.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# vim: set sw=4 sts=4 et : +# Copyright: 2008 Gentoo Foundation +# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com> +# License: GPL-2 +# +# Immortal lh! +# + +import sys, os, shutil + +DESTDIR = 'autotua_master' +SYMLINKS = True + +def print_help(): + print \ + """\ +%(file)s: Setup the django webapp for autotua +Usage: + %(file)s <where> + +Example: + %(file)s /home/me/projects/ +will create `/home/me/projects/autotua` with all the necessary files. + +By default, the directory will have the files copied. +Toggle `SYMLINKS` to symlink the files instead. + """ % {'file': sys.argv[0]} + +if len(sys.argv) == 1: + print_help() + sys.exit(1) + +os.chdir(os.path.dirname(sys.argv[0])) +cwd = os.getcwd() +if not os.path.isdir(sys.argv[1]): + os.makedirs(sys.argv[1]) +os.chdir(sys.argv[1]) + +try: + from django.core import management +except ImportError: + print "You need to install django-1.0 first." + sys.exit(1) + +if management.get_version() < '0.99': + print "You need django-1.0 to use this." + sys.exit(1) + +management.call_command('startproject', DESTDIR) + +if SYMLINKS: + os.symlink(cwd+'/autotua', DESTDIR+'/master') + for file in ['autotua_settings.py', 'urls.py']: + dest_file = DESTDIR+'/'+file + if os.path.isfile(dest_file): + os.remove(dest_file) + os.symlink(cwd+'/custom/'+file, dest_file) +else: + shutil.copytree(cwd+'/autotua', DESTDIR+'/master') + for file in ['autotua_settings.py', 'urls.py']: + shutil.copy(cwd+'/custom/'+file, DESTDIR) + +settings = open(DESTDIR+'/settings.py', 'a') +settings.write('\nfrom autotua_settings import *\n') +settings.close() + +print "All done. Now you need to run `python manage.py syncdb` after editing the database settings in %s/settings.py" % DESTDIR |