-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlaunch_mobile.py
More file actions
67 lines (57 loc) · 2.09 KB
/
Copy pathlaunch_mobile.py
File metadata and controls
67 lines (57 loc) · 2.09 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
#!/usr/bin/env python3
"""
Mobile App Launcher
Automatically handles virtual environment and launches mobile app
"""
import sys
import os
import subprocess
from pathlib import Path
def check_virtual_environment():
"""Check if we're in a virtual environment"""
return hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)
def activate_virtual_environment():
"""Activate virtual environment if available"""
venv_python = Path(".venv/Scripts/python.exe")
if venv_python.exists():
return str(venv_python)
venv_python = Path(".venv/bin/python")
if venv_python.exists():
return str(venv_python)
return None
def main():
"""Launch mobile app with proper environment"""
print("🚀 VFS Global Mobile App Launcher")
print("=" * 40)
# Check if we're already in a virtual environment
if check_virtual_environment():
print("✅ Virtual environment detected")
print("🌐 Starting mobile app...")
try:
import mobile_app
mobile_app.app.run(host='0.0.0.0', port=5000, debug=False)
except Exception as e:
print(f"❌ Error starting mobile app: {e}")
return False
else:
print("⚠️ No virtual environment detected")
# Try to find and use virtual environment
venv_python = activate_virtual_environment()
if venv_python:
print(f"🔧 Using virtual environment: {venv_python}")
try:
subprocess.run([venv_python, "mobile_app.py"], check=True)
except subprocess.CalledProcessError as e:
print(f"❌ Error running mobile app: {e}")
return False
else:
print("❌ No virtual environment found")
print("💡 Please run: python -m venv .venv")
print("💡 Then: .venv\\Scripts\\activate")
print("💡 Finally: python mobile_app.py")
return False
return True
if __name__ == "__main__":
success = main()
if not success:
sys.exit(1)