mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 04:20:17 +02:00
Bring these in line with modern Django
This commit is contained in:
parent
75d67aa1b1
commit
7ba1699dc6
@ -1,22 +1,22 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
"""Django's command-line utility for administrative tasks."""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name}}.settings.local")
|
def main() -> None:
|
||||||
|
"""Run administrative tasks."""
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{{ project_name }}.settings')
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as err:
|
except ImportError as exc:
|
||||||
# The above import may fail for some other reason. Ensure that the
|
raise ImportError(
|
||||||
# issue is really that Django is missing to avoid masking other
|
"Couldn't import Django. Are you sure it's installed and "
|
||||||
# exceptions on Python 2.
|
"available on your PYTHONPATH environment variable? Did you "
|
||||||
try:
|
"forget to activate a virtual environment?"
|
||||||
import django # noqa: F401
|
) from exc
|
||||||
except ImportError:
|
|
||||||
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 err
|
|
||||||
raise
|
|
||||||
execute_from_command_line(sys.argv)
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
32
runtests.py
32
runtests.py
@ -1,21 +1,23 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
Django's command-line utility for administrative tasks.
|
||||||
|
Modified to insert Tests as the first argument
|
||||||
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
def main() -> None:
|
||||||
|
"""Run tests"""
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as err:
|
except ImportError as exc:
|
||||||
# The above import may fail for some other reason. Ensure that the
|
raise ImportError(
|
||||||
# issue is really that Django is missing to avoid masking other
|
"Couldn't import Django. Are you sure it's installed and "
|
||||||
# exceptions on Python 2.
|
"available on your PYTHONPATH environment variable? Did you "
|
||||||
try:
|
"forget to activate a virtual environment?"
|
||||||
import django # noqa: F401
|
) from exc
|
||||||
except ImportError:
|
|
||||||
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 err # Provide context for the original error
|
|
||||||
raise # Re-raise original exception with context
|
|
||||||
|
|
||||||
execute_from_command_line(sys.argv.insert(1, "test"))
|
execute_from_command_line(sys.argv.insert(1, "test"))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user