mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 10:51:05 -05:00
Update root __init__.py:
- Add module reloading to ensure exceptions are available - Import and re-export all necessary exceptions - Maintain existing setup and teardown functions - Add version information - Update __all__ list with all exports
This commit is contained in:
@@ -1,14 +1,37 @@
|
|||||||
"""VideoArchiver cog for Red-DiscordBot"""
|
"""VideoArchiver cog for Red-DiscordBot"""
|
||||||
|
|
||||||
|
import sys
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
import importlib
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
|
|
||||||
|
# Remove modules to force reload
|
||||||
|
modules_to_reload = [
|
||||||
|
'videoarchiver.utils.exceptions',
|
||||||
|
'videoarchiver.utils'
|
||||||
|
]
|
||||||
|
for module in modules_to_reload:
|
||||||
|
if module in sys.modules:
|
||||||
|
del sys.modules[module]
|
||||||
|
|
||||||
|
# Import and reload utils
|
||||||
|
from . import utils
|
||||||
|
importlib.reload(utils)
|
||||||
|
|
||||||
from .core.base import VideoArchiver
|
from .core.base import VideoArchiver
|
||||||
from .core.initialization import initialize_cog, init_callback
|
from .core.initialization import initialize_cog, init_callback
|
||||||
from .core.cleanup import cleanup_resources
|
from .core.cleanup import cleanup_resources
|
||||||
from .exceptions import ProcessingError
|
from .utils.exceptions import (
|
||||||
|
VideoArchiverError,
|
||||||
|
CommandError,
|
||||||
|
EventError,
|
||||||
|
CogError,
|
||||||
|
ErrorContext,
|
||||||
|
ErrorSeverity,
|
||||||
|
ProcessingError
|
||||||
|
)
|
||||||
from .database import VideoArchiveDB
|
from .database import VideoArchiveDB
|
||||||
from .ffmpeg import FFmpegManager
|
from .ffmpeg import FFmpegManager
|
||||||
from .queue import EnhancedVideoQueueManager
|
from .queue import EnhancedVideoQueueManager
|
||||||
@@ -21,6 +44,11 @@ logger = logging.getLogger("VideoArchiver")
|
|||||||
# Track initialization task
|
# Track initialization task
|
||||||
_init_task: Optional[asyncio.Task] = None
|
_init_task: Optional[asyncio.Task] = None
|
||||||
|
|
||||||
|
# Version information
|
||||||
|
__version__ = "1.0.0"
|
||||||
|
__author__ = "VideoArchiver Team"
|
||||||
|
__description__ = "Video archiving cog for Red-DiscordBot"
|
||||||
|
|
||||||
async def setup(bot: Red) -> None:
|
async def setup(bot: Red) -> None:
|
||||||
"""Load VideoArchiver with proper initialization."""
|
"""Load VideoArchiver with proper initialization."""
|
||||||
try:
|
try:
|
||||||
@@ -43,6 +71,7 @@ async def setup(bot: Red) -> None:
|
|||||||
_init_task.cancel()
|
_init_task.cancel()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
async def teardown(bot: Red) -> None:
|
async def teardown(bot: Red) -> None:
|
||||||
"""Clean up when unloading."""
|
"""Clean up when unloading."""
|
||||||
try:
|
try:
|
||||||
@@ -63,13 +92,27 @@ async def teardown(bot: Red) -> None:
|
|||||||
logger.error(f"Error during teardown: {str(e)}")
|
logger.error(f"Error during teardown: {str(e)}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'VideoArchiver',
|
# Core classes
|
||||||
'VideoArchiveDB',
|
"VideoArchiver",
|
||||||
'FFmpegManager',
|
"VideoArchiveDB",
|
||||||
'EnhancedVideoQueueManager',
|
"FFmpegManager",
|
||||||
'VideoProcessor',
|
"EnhancedVideoQueueManager",
|
||||||
'ConfigManager',
|
"VideoProcessor",
|
||||||
'UpdateChecker',
|
"ConfigManager",
|
||||||
'ProcessingError'
|
"UpdateChecker",
|
||||||
|
|
||||||
|
# Base exceptions
|
||||||
|
"VideoArchiverError",
|
||||||
|
"CommandError",
|
||||||
|
"EventError",
|
||||||
|
"CogError",
|
||||||
|
"ErrorContext",
|
||||||
|
"ErrorSeverity",
|
||||||
|
"ProcessingError",
|
||||||
|
|
||||||
|
# Setup functions
|
||||||
|
"setup",
|
||||||
|
"teardown"
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user