1 #!/srv/library/wolnelektury/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)
27 print "Installing requirements"
28 os.system("%s install -r %s" % (PIP, os.path.join(PROJECT_ROOT, 'requirements.txt')))
30 print "Installing local requirements"
31 os.system("%s install -r %s" % (PIP, os.path.join(ROOT, 'etc', 'requirements.txt')))
34 ROOT = os.path.dirname(os.path.abspath(__file__))
36 PYTHON = os.path.join(ROOT, 'pythonenv', 'bin', 'python')
37 PIP = os.path.join(ROOT, 'pythonenv', 'bin', 'pip')
38 PYTHON_SITE = os.path.join(ROOT, 'pythonenv', 'lib', 'python2.6', 'site-packages')
40 PROJECT_NAME = 'wolnelektury'
41 PROJECT_ROOT = os.path.join(ROOT, 'application')
43 MEDIA_ROOT = os.path.join(ROOT, 'www', 'media')
45 ADMIN_EMAIL = 'lrekucki@gmail.com'
47 WSGI_TARGET = os.path.join(ROOT, 'www', 'wsgi', PROJECT_NAME + '.wsgi')
48 WSGI_DIR = os.path.dirname(WSGI_TARGET)
50 WSGI_USER = PROJECT_NAME
54 DOMAIN = 'lektury.staging.nowoczesnapolska.org.pl'
57 # Load local configuration
59 sys.path = [ os.path.join(ROOT, 'etc') ] + sys.path
61 from local_deployment import *
63 if __name__ == '__main__':
65 render_template(os.path.join(PROJECT_ROOT, PROJECT_NAME + '.wsgi.tmpl'), WSGI_TARGET, context=globals())
66 render_template(os.path.join(PROJECT_ROOT, PROJECT_NAME + '.vhost.tmpl'), os.path.join(ROOT, 'etc', PROJECT_NAME + '.vhost'), context=globals())