-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage.py
More file actions
89 lines (78 loc) · 2.41 KB
/
manage.py
File metadata and controls
89 lines (78 loc) · 2.41 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python3
"""
Development server management script
"""
import os
import sys
import subprocess
from pathlib import Path
def check_python_version():
"""Check Python version compatibility"""
if sys.version_info < (3, 8):
print("❌ Python 3.8 or higher is required")
sys.exit(1)
print(f"✅ Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
def install_dependencies():
"""Install project dependencies"""
print("📦 Installing dependencies...")
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print("✅ Dependencies installed successfully")
except subprocess.CalledProcessError:
print("❌ Failed to install dependencies")
sys.exit(1)
def run_tests():
"""Run test suite"""
print("🧪 Running tests...")
try:
subprocess.check_call([sys.executable, "-m", "pytest", "tests/", "-v"])
print("✅ All tests passed")
except subprocess.CalledProcessError:
print("❌ Tests failed")
sys.exit(1)
def start_server():
"""Start development server"""
print("🚀 Starting development server...")
try:
subprocess.check_call([
sys.executable, "-m", "uvicorn",
"main:app",
"--reload",
"--host", "0.0.0.0",
"--port", "8000"
])
except KeyboardInterrupt:
print("\n👋 Server stopped")
except subprocess.CalledProcessError:
print("❌ Failed to start server")
sys.exit(1)
def main():
"""Main management function"""
if len(sys.argv) < 2:
print("""
🎯 Expense Tracker API Management
Usage: python manage.py <command>
Commands:
install Install dependencies
test Run test suite
serve Start development server
dev Install + Test + Serve
""")
return
command = sys.argv[1]
check_python_version()
if command == "install":
install_dependencies()
elif command == "test":
run_tests()
elif command == "serve":
start_server()
elif command == "dev":
install_dependencies()
run_tests()
start_server()
else:
print(f"❌ Unknown command: {command}")
sys.exit(1)
if __name__ == "__main__":
main()