mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 10:51:05 -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 asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from ..utils.exceptions import (
|
try:
|
||||||
ComponentError,
|
# Try relative imports first
|
||||||
ErrorContext,
|
from ..utils.exceptions import ComponentError, ErrorContext, ErrorSeverity
|
||||||
ErrorSeverity
|
from .lifecycle import LifecycleState
|
||||||
)
|
except ImportError:
|
||||||
from ..core.lifecycle import LifecycleState
|
# 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:
|
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")
|
logger = logging.getLogger("VideoArchiver")
|
||||||
|
|
||||||
|
|
||||||
async def initialize_cog(cog: "VideoArchiver") -> None:
|
async def initialize_cog(cog: "VideoArchiver") -> None:
|
||||||
"""
|
"""
|
||||||
Initialize all components with proper error handling.
|
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:
|
def init_callback(cog: "VideoArchiver", task: asyncio.Task) -> None:
|
||||||
"""
|
"""
|
||||||
Handle initialization task completion.
|
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)
|
logger.error(f"Error in initialization callback: {str(e)}", exc_info=True)
|
||||||
# We don't raise here since this is a callback
|
# We don't raise here since this is a callback
|
||||||
|
|
||||||
|
|
||||||
def get_init_status(cog: "VideoArchiver") -> Dict[str, Any]:
|
def get_init_status(cog: "VideoArchiver") -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Get initialization status information.
|
Get initialization status information.
|
||||||
|
|||||||
Reference in New Issue
Block a user