-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage.py
More file actions
56 lines (42 loc) · 1.4 KB
/
manage.py
File metadata and controls
56 lines (42 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
# ruff: noqa: PLC0415
# Standard Library Imports
import os
import sys
from pathlib import Path
# Third Party Imports
from config.opentelemetry import configure_opentelemetry
# Main Function
def main():
"""
Main Function To Run The Django Management Commands.
Raises:
ImportError: If The Django Settings Module Cannot Be Imported.
"""
# Set The Default Django Settings Module
os.environ.setdefault(
key="DJANGO_SETTINGS_MODULE",
value="config.settings",
)
# Configure OpenTelemetry
configure_opentelemetry()
try:
# Import The execute_from_command_line Function From Django.
from django.core.management import execute_from_command_line
except ImportError as exc:
# Set Error Message
error_message: str = (
"Django Could Not Be Imported; Ensure It Is Installed, "
"Available On Your PYTHONPATH, And That Your Virtual Environment Is Activated."
)
# Raise The ImportError
raise ImportError(error_message) from exc
# Append The Current Path To The Python Path
current_path: Path = Path(__file__).parent.resolve()
sys.path.append(str(current_path / "apps"))
# Execute The Django Management Commands
execute_from_command_line(sys.argv)
# If The Script Is Run Directly
if __name__ == "__main__":
# Call The Main Function
main()