feat: hook manager
This commit is contained in:
@ -12,14 +12,15 @@ from pathlib import Path
|
||||
import yaml
|
||||
|
||||
from scientific_surfing.models import Config
|
||||
from scientific_surfing.storage import StorageManager
|
||||
from scientific_surfing.subscription_manager import SubscriptionManager
|
||||
|
||||
|
||||
class CoreConfigManager:
|
||||
"""Manages user configuration with import, export, and edit operations."""
|
||||
|
||||
def __init__(self):
|
||||
self.storage = StorageManager()
|
||||
def __init__(self, subscription_manager: SubscriptionManager):
|
||||
self.subscription_manager = subscription_manager
|
||||
self.storage = subscription_manager.storage
|
||||
self.config_file = self.storage.config_dir / "core-config.yaml"
|
||||
self.default_config_path = Path(__file__).parent / "templates" / "default-core-config.yaml"
|
||||
|
||||
@ -221,12 +222,17 @@ class CoreConfigManager:
|
||||
cmd = [str(hook_path), str(config_file_path)]
|
||||
|
||||
print(f"🔧 Executing hook: {hook_path.name}")
|
||||
env = os.environ.copy()
|
||||
env['PYTHONIOENCODING'] = 'utf-8'
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
cwd=hook_path.parent,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30
|
||||
timeout=30,
|
||||
encoding="utf-8",
|
||||
shell=True,
|
||||
env=env,
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
@ -276,8 +282,7 @@ class CoreConfigManager:
|
||||
config = self.load_config()
|
||||
|
||||
# Load subscriptions to get active subscription
|
||||
subscription_manager = SubscriptionManager()
|
||||
active_subscription = subscription_manager.subscriptions_data.get_active_subscription()
|
||||
active_subscription = self.subscription_manager.subscriptions_data.get_active_subscription()
|
||||
|
||||
if not active_subscription:
|
||||
print("❌ No active subscription found")
|
||||
|
||||
Reference in New Issue
Block a user