91 lines
2.5 KiB
Python
Executable File
91 lines
2.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Quick scouting update script for Paper Dynasty.
|
|
|
|
This script runs from the card-creation directory and:
|
|
1. Runs scouting_batters.py to generate batting reports
|
|
2. Runs scouting_pitchers.py to generate pitching reports
|
|
3. Uploads generated CSV files to database server via SSH
|
|
|
|
Usage:
|
|
cd /mnt/NV2/Development/paper-dynasty/card-creation
|
|
uv run scripts/update_scouting.py
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
import logging
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(message)s'
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def run_command(cmd: list[str], description: str) -> bool:
|
|
"""Run a command and return success status."""
|
|
logger.info(f"→ {description}...")
|
|
try:
|
|
subprocess.run(cmd, check=True, cwd=Path(__file__).parent.parent)
|
|
logger.info(f"✓ {description} complete")
|
|
return True
|
|
except subprocess.CalledProcessError as e:
|
|
logger.error(f"✗ {description} failed: {e}")
|
|
return False
|
|
|
|
|
|
def main():
|
|
"""Execute the scouting update workflow."""
|
|
logger.info("=" * 60)
|
|
logger.info("Paper Dynasty - Scouting Update")
|
|
logger.info("=" * 60)
|
|
|
|
# Step 1: Generate batting scouting
|
|
if not run_command(
|
|
['uv', 'run', 'scouting_batters.py'],
|
|
"Generating batting scouting reports"
|
|
):
|
|
return 1
|
|
|
|
# Step 2: Generate pitching scouting
|
|
if not run_command(
|
|
['uv', 'run', 'scouting_pitchers.py'],
|
|
"Generating pitching scouting reports"
|
|
):
|
|
return 1
|
|
|
|
# Step 3: Verify files exist
|
|
scouting_dir = Path(__file__).parent.parent / 'scouting'
|
|
required_files = [
|
|
'batting-basic.csv',
|
|
'batting-ratings.csv',
|
|
'pitching-basic.csv',
|
|
'pitching-ratings.csv'
|
|
]
|
|
|
|
logger.info("→ Verifying generated files...")
|
|
missing = [f for f in required_files if not (scouting_dir / f).exists()]
|
|
if missing:
|
|
logger.error(f"✗ Missing files: {', '.join(missing)}")
|
|
return 1
|
|
logger.info(f"✓ All {len(required_files)} files verified")
|
|
|
|
# Step 4: Upload to database server
|
|
files_to_upload = [str(scouting_dir / f) for f in required_files]
|
|
if not run_command(
|
|
['scp', *files_to_upload, 'sba-db:/home/cal/container-data/pd-database/storage/'],
|
|
"Uploading files to database server"
|
|
):
|
|
return 1
|
|
|
|
logger.info("=" * 60)
|
|
logger.info("✓ Scouting update complete!")
|
|
logger.info("=" * 60)
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|