1 #!/srv/library/redakcja/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'))
33 PYTHON = os.path.join(ROOT, 'pythonenv', 'bin', 'python')
34 PYTHON_SITE = os.path.join(ROOT, 'pythonenv', 'lib', 'python2.6', 'site-packages')
36 PROJECT_NAME = 'redakcja'
37 PROJECT_ROOT = os.path.join(ROOT, 'application')
39 MEDIA_ROOT = os.path.join(ROOT, 'www', 'media')
41 ADMIN_EMAIL = 'lrekucki@gmail.com'
43 WSGI_TARGET = os.path.join(ROOT, 'www', 'wsgi', PROJECT_NAME + '.wsgi')
44 WSGI_DIR = os.path.dirname(WSGI_TARGET)
46 WSGI_USER = PROJECT_NAME
50 DOMAIN = 'redakcja.wolnelektury.pl'
51 DOMAIN_ALIASES = 'redakcja.nowoczesnapolska.org.pl'
54 # Load local configuration
56 sys.path = [ os.path.join(ROOT, 'etc') ] + sys.path
58 from local_deployment import *
60 if __name__ == '__main__':
62 render_template(os.path.join(PROJECT_ROOT, PROJECT_NAME + '.wsgi.template'), WSGI_TARGET, context=globals())
63 render_template(os.path.join(PROJECT_ROOT, PROJECT_NAME + '.vhost.template'), os.path.join(ROOT, 'etc', PROJECT_NAME + '.vhost'), context=globals())