Function bodies 108 total
ensure_venv function · python · L26-L45 (20 LOC)skills/extensions/notebooklm/scripts/run.py
def ensure_venv():
"""Ensure virtual environment exists"""
skill_dir = Path(__file__).parent.parent
venv_dir = skill_dir / ".venv"
setup_script = skill_dir / "scripts" / "setup_environment.py"
# Check if venv exists
if not venv_dir.exists():
print("🔧 First-time setup: Creating virtual environment...")
print(" This may take a minute...")
# Run setup with system Python
result = subprocess.run([sys.executable, str(setup_script)])
if result.returncode != 0:
print("❌ Failed to set up environment")
sys.exit(1)
print("✅ Environment ready!")
return get_venv_python()main function · python · L48-L98 (51 LOC)skills/extensions/notebooklm/scripts/run.py
def main():
"""Main runner"""
if len(sys.argv) < 2:
print("Usage: python run.py <script_name> [args...]")
print("\nAvailable scripts:")
print(" ask_question.py - Query NotebookLM")
print(" notebook_manager.py - Manage notebook library")
print(" session_manager.py - Manage sessions")
print(" auth_manager.py - Handle authentication")
print(" cleanup_manager.py - Clean up skill data")
sys.exit(1)
script_name = sys.argv[1]
script_args = sys.argv[2:]
# Handle both "scripts/script.py" and "script.py" formats
if script_name.startswith('scripts/'):
# Remove the scripts/ prefix if provided
script_name = script_name[8:] # len('scripts/') = 8
# Ensure .py extension
if not script_name.endswith('.py'):
script_name += '.py'
# Get script path
skill_dir = Path(__file__).parent.parent
script_path = skill_dir / "scripts" / script_name
if not script_pSkillEnvironment.__init__ method · python · L17-L29 (13 LOC)skills/extensions/notebooklm/scripts/setup_environment.py
def __init__(self):
# Skill directory paths
self.skill_dir = Path(__file__).parent.parent
self.venv_dir = self.skill_dir / ".venv"
self.requirements_file = self.skill_dir / "requirements.txt"
# Python executable in venv
if os.name == 'nt': # Windows
self.venv_python = self.venv_dir / "Scripts" / "python.exe"
self.venv_pip = self.venv_dir / "Scripts" / "pip.exe"
else: # Unix/Linux/Mac
self.venv_python = self.venv_dir / "bin" / "python"
self.venv_pip = self.venv_dir / "bin" / "pip"SkillEnvironment.ensure_venv method · python · L31-L94 (64 LOC)skills/extensions/notebooklm/scripts/setup_environment.py
def ensure_venv(self) -> bool:
"""Ensure virtual environment exists and is set up"""
# Check if we're already in the correct venv
if self.is_in_skill_venv():
print("✅ Already running in skill virtual environment")
return True
# Create venv if it doesn't exist
if not self.venv_dir.exists():
print(f"🔧 Creating virtual environment in {self.venv_dir.name}/")
try:
venv.create(self.venv_dir, with_pip=True)
print("✅ Virtual environment created")
except Exception as e:
print(f"❌ Failed to create venv: {e}")
return False
# Install/update dependencies
if self.requirements_file.exists():
print("📦 Installing dependencies...")
try:
# Upgrade pip first
subprocess.run(
[str(self.venv_pip), "install", "--upgrade", "pip"],
cSkillEnvironment.is_in_skill_venv method · python · L96-L102 (7 LOC)skills/extensions/notebooklm/scripts/setup_environment.py
def is_in_skill_venv(self) -> bool:
"""Check if we're already running in the skill's venv"""
if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix):
# We're in a venv, check if it's ours
venv_path = Path(sys.prefix)
return venv_path == self.venv_dir
return FalseSkillEnvironment.run_script method · python · L110-L136 (27 LOC)skills/extensions/notebooklm/scripts/setup_environment.py
def run_script(self, script_name: str, args: list = None) -> int:
"""Run a script with the virtual environment"""
script_path = self.skill_dir / "scripts" / script_name
if not script_path.exists():
print(f"❌ Script not found: {script_path}")
return 1
# Ensure venv is set up
if not self.ensure_venv():
print("❌ Failed to set up environment")
return 1
# Build command
cmd = [str(self.venv_python), str(script_path)]
if args:
cmd.extend(args)
print(f"🚀 Running: {script_name} with venv Python")
try:
# Run the script with venv Python
result = subprocess.run(cmd)
return result.returncode
except Exception as e:
print(f"❌ Failed to run script: {e}")
return 1SkillEnvironment.activate_instructions method · python · L138-L145 (8 LOC)skills/extensions/notebooklm/scripts/setup_environment.py
def activate_instructions(self) -> str:
"""Get instructions for manual activation"""
if os.name == 'nt':
activate = self.venv_dir / "Scripts" / "activate.bat"
return f"Run: {activate}"
else:
activate = self.venv_dir / "bin" / "activate"
return f"Run: source {activate}"Same scanner, your repo: https://repobility.com — Repobility
main function · python · L148-L200 (53 LOC)skills/extensions/notebooklm/scripts/setup_environment.py
def main():
"""Main entry point for environment setup"""
import argparse
parser = argparse.ArgumentParser(
description='Setup NotebookLM skill environment'
)
parser.add_argument(
'--check',
action='store_true',
help='Check if environment is set up'
)
parser.add_argument(
'--run',
help='Run a script with the venv (e.g., --run ask_question.py)'
)
parser.add_argument(
'args',
nargs='*',
help='Arguments to pass to the script'
)
args = parser.parse_args()
env = SkillEnvironment()
if args.check:
if env.venv_dir.exists():
print(f"✅ Virtual environment exists: {env.venv_dir}")
print(f" Python: {env.get_python_executable()}")
print(f" To activate manually: {env.activate_instructions()}")
else:
print(f"❌ No virtual environment found")
print(f" Run setup_environment.py to create it")
‹ prevpage 3 / 3