PyInventory/inventory_project/manage.py

42 wiersze
1.2 KiB
Python
Czysty Zwykły widok Historia

2020-10-16 15:54:34 +00:00
import os
import sys
2020-11-13 20:52:19 +00:00
2021-04-05 13:23:32 +00:00
from django import __version__ as django_version
2020-11-13 20:52:19 +00:00
2021-04-05 13:23:32 +00:00
from inventory import __version__
2021-04-28 15:38:06 +00:00
def main(argv):
2021-04-05 13:23:32 +00:00
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'inventory_project.settings.local')
2020-11-13 20:52:19 +00:00
2021-04-28 15:38:06 +00:00
if '--version' not in argv:
2021-04-05 13:23:32 +00:00
print(f'PyInventory v{__version__} (Django v{django_version})', file=sys.stderr)
print(f'DJANGO_SETTINGS_MODULE={os.environ["DJANGO_SETTINGS_MODULE"]!r}', file=sys.stderr)
2020-11-13 20:52:19 +00:00
2020-10-16 15:54:34 +00:00
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
try:
2021-04-28 15:38:06 +00:00
execute_from_command_line(argv)
except Exception as err:
from bx_py_utils.error_handling import print_exc_plus
2023-07-21 05:50:19 +00:00
print_exc_plus(err)
raise
2020-10-16 15:54:34 +00:00
2021-04-05 13:23:32 +00:00
def start_test_server():
"""
Entrypoint for "[tool.poetry.scripts]" script started by devshell command.
"""
main(argv=[__file__, "run_testserver"] + sys.argv[1:])
2021-04-05 13:23:32 +00:00
2020-10-16 15:54:34 +00:00
if __name__ == '__main__':
2021-04-28 15:38:06 +00:00
main(argv=sys.argv)