📦 deps(thirdparty): update snapshots
This commit is contained in:
@@ -5,10 +5,20 @@ Ensures all scripts run with the correct virtual environment
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
ALLOWED_SCRIPTS = {
|
||||
"ask_question.py",
|
||||
"notebook_manager.py",
|
||||
"session_manager.py",
|
||||
"auth_manager.py",
|
||||
"cleanup_manager.py",
|
||||
}
|
||||
SCRIPT_NAME_RE = re.compile(r"^[A-Za-z0-9_-]+\.py$")
|
||||
|
||||
|
||||
def get_venv_python():
|
||||
"""Get the virtual environment Python executable"""
|
||||
@@ -59,6 +69,7 @@ def main():
|
||||
|
||||
script_name = sys.argv[1]
|
||||
script_args = sys.argv[2:]
|
||||
scripts_dir = (Path(__file__).parent.parent / "scripts").resolve()
|
||||
|
||||
# Handle both "scripts/script.py" and "script.py" formats
|
||||
if script_name.startswith('scripts/'):
|
||||
@@ -68,10 +79,18 @@ def main():
|
||||
# Ensure .py extension
|
||||
if not script_name.endswith('.py'):
|
||||
script_name += '.py'
|
||||
if not SCRIPT_NAME_RE.match(script_name) or script_name not in ALLOWED_SCRIPTS:
|
||||
print(f"❌ Unsupported script: {script_name}")
|
||||
sys.exit(1)
|
||||
|
||||
# Get script path
|
||||
skill_dir = Path(__file__).parent.parent
|
||||
script_path = skill_dir / "scripts" / script_name
|
||||
script_path = (scripts_dir / script_name).resolve()
|
||||
try:
|
||||
script_path.relative_to(scripts_dir)
|
||||
except ValueError:
|
||||
print(f"❌ Script path escapes scripts directory: {script_name}")
|
||||
sys.exit(1)
|
||||
|
||||
if not script_path.exists():
|
||||
print(f"❌ Script not found: {script_name}")
|
||||
@@ -83,13 +102,9 @@ def main():
|
||||
# Ensure venv exists and get Python executable
|
||||
venv_python = ensure_venv()
|
||||
|
||||
# Build command
|
||||
cmd = [str(venv_python), str(script_path)] + script_args
|
||||
|
||||
# Run the script
|
||||
# Replace this runner with the selected venv Python process.
|
||||
try:
|
||||
result = subprocess.run(cmd)
|
||||
sys.exit(result.returncode)
|
||||
os.execv(str(venv_python), [str(venv_python), str(script_path)] + script_args)
|
||||
except KeyboardInterrupt:
|
||||
print("\n⚠️ Interrupted by user")
|
||||
sys.exit(130)
|
||||
@@ -99,4 +114,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user