29 lines
1 KiB
Python
Executable file
29 lines
1 KiB
Python
Executable file
#!/usr/bin/env python
|
|
import os
|
|
import sys
|
|
from dotenv import load_dotenv
|
|
from os import path
|
|
|
|
if __name__ == '__main__':
|
|
env_path = path.join(path.dirname(path.realpath(__file__)), '.env')
|
|
load_dotenv(verbose=True,dotenv_path=env_path)
|
|
|
|
check_env_vars = ['POSTGRES_DB', 'POSTGRES_HOST', 'POSTGRES_PASSWORD',
|
|
'POSTGRES_USER', 'DEBUG', 'ALLOWED_HOSTS']
|
|
|
|
for key in check_env_vars:
|
|
if key not in os.environ:
|
|
sys.stderr.write('The mandatory environment ' \
|
|
'variable ' + key + ' is not set\n')
|
|
sys.exit(1)
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'arrowcounter.settings')
|
|
try:
|
|
from django.core.management import execute_from_command_line
|
|
except ImportError as exc:
|
|
raise ImportError(
|
|
"Couldn't import Django. Are you sure it's installed and "
|
|
"available on your PYTHONPATH environment variable? Did you "
|
|
"forget to activate a virtual environment?"
|
|
) from exc
|
|
execute_from_command_line(sys.argv)
|