~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to mainpage/wlwebsite_wsgi.py

  • Committer: Holger Rapp
  • Date: 2019-06-21 18:34:42 UTC
  • mfrom: (540.1.3 update_ops_script)
  • Revision ID: sirver@gmx.de-20190621183442-y2ulybzr0rdvfefd
Adapt the update script for the new server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import sys
 
3
 
 
4
parent_dir = lambda dir: os.path.abspath(os.path.join(dir, os.pardir))
 
5
 
 
6
code_directory = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
 
7
 
 
8
current_dir = code_directory
 
9
activate_this = None
 
10
while current_dir != '/':
 
11
    current_dir = parent_dir(current_dir)
 
12
    if os.path.exists(os.path.join(current_dir, 'bin', 'activate_this.py')):
 
13
        activate_this = os.path.join(current_dir, 'bin', 'activate_this.py')
 
14
        break
 
15
 
 
16
if activate_this is None:
 
17
    raise RuntimeException('Could not find virtualenv to start up!')
 
18
 
 
19
exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this))
 
20
 
 
21
sys.path.append(parent_dir(code_directory))
 
22
sys.path.append(code_directory)
 
23
sys.path.append(os.path.join(code_directory, 'widelands'))
 
24
 
 
25
os.environ['DJANGO_SETTINGS_MODULE'] = 'mainpage.settings'
 
26
 
 
27
if os.path.exists('/usr/games'):
 
28
    os.environ['PATH'] += ':/usr/games'
 
29
 
 
30
from django.core.wsgi import get_wsgi_application
 
31
application = get_wsgi_application()