mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 02:41:06 -05:00
fix(core): add fallback to absolute imports in initialization.py
This commit is contained in:
@@ -4,18 +4,24 @@ from typing import TYPE_CHECKING, Optional, Dict, Any
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from ..utils.exceptions import (
|
||||
ComponentError,
|
||||
ErrorContext,
|
||||
ErrorSeverity
|
||||
)
|
||||
from ..core.lifecycle import LifecycleState
|
||||
try:
|
||||
# Try relative imports first
|
||||
from ..utils.exceptions import ComponentError, ErrorContext, ErrorSeverity
|
||||
from .lifecycle import LifecycleState
|
||||
except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
from videoarchiver.utils.exceptions import ComponentError, ErrorContext, ErrorSeverity
|
||||
from videoarchiver.core.lifecycle import LifecycleState
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..core.base import VideoArchiver
|
||||
try:
|
||||
from .base import VideoArchiver
|
||||
except ImportError:
|
||||
from videoarchiver.core.base import VideoArchiver
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
|
||||
async def initialize_cog(cog: "VideoArchiver") -> None:
|
||||
"""
|
||||
Initialize all components with proper error handling.
|
||||
@@ -46,6 +52,7 @@ async def initialize_cog(cog: "VideoArchiver") -> None:
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def init_callback(cog: "VideoArchiver", task: asyncio.Task) -> None:
|
||||
"""
|
||||
Handle initialization task completion.
|
||||
@@ -74,6 +81,7 @@ def init_callback(cog: "VideoArchiver", task: asyncio.Task) -> None:
|
||||
logger.error(f"Error in initialization callback: {str(e)}", exc_info=True)
|
||||
# We don't raise here since this is a callback
|
||||
|
||||
|
||||
def get_init_status(cog: "VideoArchiver") -> Dict[str, Any]:
|
||||
"""
|
||||
Get initialization status information.
|
||||
|
||||
Reference in New Issue
Block a user