1 #!/srv/internal/cas/pythonenv/bin/python
2 from __future__ import with_statement
8 from string import Template
10 def render_template(source, dest, context={}):
11 print "Rendering template:",
12 with open(source, 'rb') as source_file:
13 t = Template(source_file.read())
14 with open(dest, 'wb') as dest_file:
15 dest_file.write(t.safe_substitute(context))
19 print "Restarting wsgi application:",
20 os.system("touch %s" % WSGI_TARGET)
23 def update_application():
24 print "Updating repository.",
25 os.system("cd %s; git pull" % PROJECT_ROOT)
26 print "Installing requirements"
27 os.system("pip install -r %s" % os.path.join(PROJECT_ROOT, 'requirements.txt'))
28 print "Installing local requirements"
29 os.system("pip install -r %s" % os.path.join(ROOT, 'etc', 'requirements.txt'))
32 ROOT = os.path.dirname(os.path.abspath(__file__))
34 PYTHON = os.path.join(ROOT, 'pythonenv', 'bin', 'python')
35 PYTHON_SITE = os.path.join(ROOT, 'pythonenv', 'lib', 'python2.6', 'site-packages')
37 PROJECT_NAME = 'redakcja'
38 PROJECT_ROOT = os.path.join(ROOT, 'app')
40 MEDIA_ROOT = os.path.join(ROOT, 'www', 'media')
42 ADMIN_EMAIL = 'lrekucki@gmail.com'
44 WSGI_TARGET = os.path.join(ROOT, 'www', 'wsgi', PROJECT_NAME + '.wsgi')
45 WSGI_DIR = os.path.dirname(WSGI_TARGET)
47 WSGI_USER = PROJECT_NAME
51 DOMAIN = 'redakcja.wolnelektury.pl'
52 DOMAIN_ALIASES = 'redakcja.nowoczesnapolska.org.pl'
55 # Load local configuration
57 sys.path = [ os.path.join(ROOT, 'etc') ] + sys.path
59 from local_deployment import *
61 if __name__ == '__main__':
63 render_template(os.path.join(PROJECT_ROOT, PROJECT_NAME + '.wsgi.template'), WSGI_TARGET, context=globals())
64 render_template(os.path.join(PROJECT_ROOT, PROJECT_NAME + '.vhost.template'), os.path.join(ROOT, 'etc', PROJECT_NAME + '.vhost'), context=globals())