added (example) activate_this.py

This commit is contained in:
Tobias Kurze
2019-04-15 16:12:35 +02:00
parent dceefb0d69
commit 7f545e25f6
3 changed files with 43 additions and 9 deletions

View File

@@ -7,15 +7,15 @@
```xml
<VirtualHost *:80>
ServerName vue-test
ServerAlias vue-test.local
ServerName lrc
ServerAlias lrc.local
ServerAdmin kurze@kit.edu
ErrorLog "/var/log/httpd/vue-test.local-error_log"
CustomLog "/var/log/httpd/vue-test.local-access_log" common
ErrorLog "/var/log/httpd/lrc.local-error_log"
CustomLog "/var/log/httpd/lrc.local-access_log" common
DocumentRoot /srv/http/vue_test/
WSGIScriptAlias / /srv/http/vue_test/app.wsgi
<Directory "/srv/http/vue_test/">
DocumentRoot /srv/http/lrc/
WSGIScriptAlias / /srv/http/lrc/app.wsgi
<Directory "/srv/http/lrc/">
Allow from all
</Directory>
</VirtualHost>

34
activate_this.py Normal file
View File

@@ -0,0 +1,34 @@
"""By using execfile(this_file, dict(__file__=this_file)) you will
activate this virtualenv environment.
This can be used when you must use an existing Python interpreter, not
the virtualenv bin/python
"""
try:
__file__
except NameError:
raise AssertionError(
"You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))")
import sys
import os
old_os_path = os.environ.get('PATH', '')
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if sys.platform == 'win32':
site_packages = os.path.join(base, 'Lib', 'site-packages')
else:
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
prev_sys_path = list(sys.path)
import site
site.addsitedir(site_packages)
sys.real_prefix = sys.prefix
sys.prefix = base
# Move the added items to the front of the path:
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path

View File

@@ -1,6 +1,6 @@
#!/usr/bin/python
activate_this = '/srv/http/vue_test/venv/bin/activate_this.py'
activate_this = '/srv/http/lrc/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
@@ -8,7 +8,7 @@ import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, "/srv/http/vue_test/")
sys.path.insert(0, "/srv/http/lrc/")
from backend import app as application
application.secret_key = 'Add your secret key'