camie-tagger / game /run_game.py
Camais03's picture
V1.5
29b445b verified
#!/usr/bin/env python3
import os
import sys
import subprocess
def run_game():
# Check if game app.py exists
game_path = "game.py"
if not os.path.exists(game_path):
print(f"Error: {game_path} not found")
return False
# Get parent directory path (where venv is located)
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Get the path to streamlit in the virtual environment (in parent directory)
if sys.platform == "win32":
streamlit_path = os.path.join(parent_dir, "venv", "Scripts", "streamlit.exe")
else:
streamlit_path = os.path.join(parent_dir, "venv", "bin", "streamlit")
if not os.path.exists(streamlit_path):
print(f"Error: Streamlit not found at {streamlit_path}")
print("Make sure you've run setup.py first to create the virtual environment")
return False
print("=" * 60)
print(" Starting Tag Collector Game")
print("=" * 60)
# Run Streamlit app
try:
command = [streamlit_path, "run", game_path, "--server.port", "8502"]
subprocess.run(command, check=True)
return True
except subprocess.CalledProcessError as e:
print(f"Error running the game: {e}")
return False
except KeyboardInterrupt:
print("\nGame stopped by user")
return True
if __name__ == "__main__":
success = run_game()
sys.exit(0 if success else 1)