mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 02:41:06 -05:00
fixed imports again
This commit is contained in:
@@ -8,10 +8,17 @@ from typing import Any, ClassVar, Dict, List, Optional, Tuple, TYPE_CHECKING
|
||||
import discord # type: ignore
|
||||
from discord.ext import commands # type: ignore
|
||||
|
||||
# from videoarchiver.core.types import ComponentState, ProcessorState, ComponentStatus, IComponent, IConfigManager, IQueueManager
|
||||
# from videoarchiver.processor.constants import REACTIONS
|
||||
# from videoarchiver.utils.progress_tracker import ProgressTracker
|
||||
# from videoarchiver.utils.exceptions import ProcessorError
|
||||
from ..core.types import (
|
||||
ComponentState,
|
||||
ProcessorState,
|
||||
ComponentStatus,
|
||||
IComponent,
|
||||
IConfigManager,
|
||||
IQueueManager,
|
||||
)
|
||||
from .constants import REACTIONS
|
||||
from ..utils.progress_tracker import ProgressTracker
|
||||
from ..utils.exceptions import ProcessorError
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
@@ -45,11 +52,13 @@ class OperationTracker:
|
||||
) -> None:
|
||||
"""End tracking an operation"""
|
||||
if op_id in self.operations:
|
||||
self.operations[op_id].update({
|
||||
"end_time": datetime.utcnow(),
|
||||
"status": "success" if success else "error",
|
||||
"error": error,
|
||||
})
|
||||
self.operations[op_id].update(
|
||||
{
|
||||
"end_time": datetime.utcnow(),
|
||||
"status": "success" if success else "error",
|
||||
"error": error,
|
||||
}
|
||||
)
|
||||
# Move to history
|
||||
self.operation_history.append(self.operations.pop(op_id))
|
||||
# Update counts
|
||||
@@ -60,7 +69,7 @@ class OperationTracker:
|
||||
|
||||
# Cleanup old history if needed
|
||||
if len(self.operation_history) > self.MAX_HISTORY:
|
||||
self.operation_history = self.operation_history[-self.MAX_HISTORY:]
|
||||
self.operation_history = self.operation_history[-self.MAX_HISTORY :]
|
||||
|
||||
def get_active_operations(self) -> Dict[str, Dict[str, Any]]:
|
||||
"""Get currently active operations"""
|
||||
@@ -114,11 +123,13 @@ class HealthMonitor:
|
||||
self.last_check = datetime.utcnow()
|
||||
|
||||
# Check component health
|
||||
self.health_status.update({
|
||||
"queue_handler": self.processor.queue_handler.is_healthy(),
|
||||
"message_handler": self.processor.message_handler.is_healthy(),
|
||||
"progress_tracker": self.progress_tracker.is_healthy(),
|
||||
})
|
||||
self.health_status.update(
|
||||
{
|
||||
"queue_handler": self.processor.queue_handler.is_healthy(),
|
||||
"message_handler": self.processor.message_handler.is_healthy(),
|
||||
"progress_tracker": self.progress_tracker.is_healthy(),
|
||||
}
|
||||
)
|
||||
|
||||
# Check operation health
|
||||
op_stats = self.processor.operation_tracker.get_operation_stats()
|
||||
@@ -168,8 +179,12 @@ class VideoProcessor(IComponent):
|
||||
from .cleanup_manager import CleanupManager, CleanupStrategy
|
||||
|
||||
# Initialize handlers
|
||||
self.queue_handler: "QueueHandler" = QueueHandler(bot, config_manager, components)
|
||||
self.message_handler: "MessageHandler" = MessageHandler(bot, config_manager, queue_manager)
|
||||
self.queue_handler: "QueueHandler" = QueueHandler(
|
||||
bot, config_manager, components
|
||||
)
|
||||
self.message_handler: "MessageHandler" = MessageHandler(
|
||||
bot, config_manager, queue_manager
|
||||
)
|
||||
self.cleanup_manager: "CleanupManager" = CleanupManager(
|
||||
self.queue_handler, ffmpeg_mgr, CleanupStrategy.NORMAL
|
||||
)
|
||||
@@ -243,9 +258,7 @@ class VideoProcessor(IComponent):
|
||||
|
||||
async def cleanup(self) -> None:
|
||||
"""Clean up resources and stop processing"""
|
||||
op_id = self.operation_tracker.start_operation(
|
||||
"cleanup", {"type": "normal"}
|
||||
)
|
||||
op_id = self.operation_tracker.start_operation("cleanup", {"type": "normal"})
|
||||
|
||||
try:
|
||||
self._state = ProcessorState.SHUTDOWN
|
||||
@@ -260,9 +273,7 @@ class VideoProcessor(IComponent):
|
||||
|
||||
async def force_cleanup(self) -> None:
|
||||
"""Force cleanup of resources"""
|
||||
op_id = self.operation_tracker.start_operation(
|
||||
"cleanup", {"type": "force"}
|
||||
)
|
||||
op_id = self.operation_tracker.start_operation("cleanup", {"type": "force"})
|
||||
|
||||
try:
|
||||
self._state = ProcessorState.SHUTDOWN
|
||||
@@ -321,5 +332,5 @@ class VideoProcessor(IComponent):
|
||||
"operations": self.operation_tracker.get_operation_stats(),
|
||||
"active_operations": self.operation_tracker.get_active_operations(),
|
||||
"health_status": self.health_monitor.health_status,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -4,33 +4,45 @@ import asyncio
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from enum import auto, Enum
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Set, Tuple, TypedDict, TYPE_CHECKING
|
||||
from typing import (
|
||||
Any,
|
||||
ClassVar,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Tuple,
|
||||
TypedDict,
|
||||
TYPE_CHECKING,
|
||||
)
|
||||
|
||||
import discord # type: ignore
|
||||
from discord.ext import commands # type: ignore
|
||||
|
||||
try:
|
||||
# Try relative imports first
|
||||
from ..config_manager import ConfigManager
|
||||
from .constants import REACTIONS
|
||||
from .message_validator import MessageValidator, ValidationError
|
||||
from .url_extractor import URLExtractor, URLMetadata
|
||||
from ..queue.types import QueuePriority
|
||||
from ..utils.exceptions import MessageHandlerError
|
||||
except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.config_manager import ConfigManager
|
||||
# from videoarchiver.processor.constants import REACTIONS
|
||||
# from videoarchiver.processor.message_validator import MessageValidator, ValidationError
|
||||
# from videoarchiver.processor.url_extractor import URLExtractor, URLMetadata
|
||||
# from videoarchiver.queue.types import QueuePriority
|
||||
# from videoarchiver.utils.exceptions import MessageHandlerError
|
||||
# try:
|
||||
# Try relative imports first
|
||||
from ..config_manager import ConfigManager
|
||||
from .constants import REACTIONS
|
||||
from .message_validator import MessageValidator, ValidationError
|
||||
from .url_extractor import URLExtractor, URLMetadata
|
||||
from ..queue.types import QueuePriority
|
||||
from ..utils.exceptions import MessageHandlerError
|
||||
|
||||
# except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.config_manager import ConfigManager
|
||||
# from videoarchiver.processor.constants import REACTIONS
|
||||
# from videoarchiver.processor.message_validator import MessageValidator, ValidationError
|
||||
# from videoarchiver.processor.url_extractor import URLExtractor, URLMetadata
|
||||
# from videoarchiver.queue.types import QueuePriority
|
||||
# from videoarchiver.utils.exceptions import MessageHandlerError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
try:
|
||||
from ..queue.manager import EnhancedVideoQueueManager
|
||||
except ImportError:
|
||||
# from videoarchiver.queue.manager import EnhancedVideoQueueManager
|
||||
# try:
|
||||
from ..queue.manager import EnhancedVideoQueueManager
|
||||
|
||||
# except ImportError:
|
||||
# from videoarchiver.queue.manager import EnhancedVideoQueueManager
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
@@ -337,7 +349,7 @@ class MessageHandler:
|
||||
channel_id=message.channel.id,
|
||||
guild_id=message.guild.id,
|
||||
author_id=message.author.id,
|
||||
priority=QueuePriority.NORMAL.value
|
||||
priority=QueuePriority.NORMAL.value,
|
||||
)
|
||||
except Exception as e:
|
||||
raise MessageHandlerError(f"Queue processing failed: {str(e)}")
|
||||
|
||||
@@ -7,10 +7,10 @@ from typing import Dict, Optional, Tuple, List, Any, Callable, Set, TypedDict, C
|
||||
from datetime import datetime
|
||||
import discord # type: ignore
|
||||
|
||||
try:
|
||||
#try:
|
||||
# Try relative imports first
|
||||
from ..utils.exceptions import ValidationError
|
||||
except ImportError:
|
||||
from ..utils.exceptions import ValidationError
|
||||
#except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.utils.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -8,27 +8,28 @@ from typing import Optional, Dict, Any, List, Tuple, Set, TypedDict, ClassVar, C
|
||||
from datetime import datetime
|
||||
import discord # type: ignore
|
||||
|
||||
try:
|
||||
# Try relative imports first
|
||||
from .. import utils
|
||||
from ..database.video_archive_db import VideoArchiveDB
|
||||
from ..utils.download_manager import DownloadManager
|
||||
from ..utils.message_manager import MessageManager
|
||||
from ..utils.exceptions import QueueHandlerError
|
||||
from ..queue.models import QueueItem
|
||||
from ..config_manager import ConfigManager
|
||||
from . import progress_tracker # Import from processor package
|
||||
from .constants import REACTIONS
|
||||
except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.database.video_archive_db import VideoArchiveDB
|
||||
# from videoarchiver.utils.download_manager import DownloadManager
|
||||
# from videoarchiver.utils.message_manager import MessageManager
|
||||
# from videoarchiver.utils.exceptions import QueueHandlerError
|
||||
# from videoarchiver.queue.models import QueueItem
|
||||
# from videoarchiver.config_manager import ConfigManager
|
||||
# from videoarchiver.processor import progress_tracker # Import from processor package
|
||||
# from videoarchiver.processor.constants import REACTIONS
|
||||
# try:
|
||||
# Try relative imports first
|
||||
from .. import utils
|
||||
from ..database.video_archive_db import VideoArchiveDB
|
||||
from ..utils.download_manager import DownloadManager
|
||||
from ..utils.message_manager import MessageManager
|
||||
from ..utils.exceptions import QueueHandlerError
|
||||
from ..queue.models import QueueItem
|
||||
from ..config_manager import ConfigManager
|
||||
from . import progress_tracker # Import from processor package
|
||||
from .constants import REACTIONS
|
||||
|
||||
# except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.database.video_archive_db import VideoArchiveDB
|
||||
# from videoarchiver.utils.download_manager import DownloadManager
|
||||
# from videoarchiver.utils.message_manager import MessageManager
|
||||
# from videoarchiver.utils.exceptions import QueueHandlerError
|
||||
# from videoarchiver.queue.models import QueueItem
|
||||
# from videoarchiver.config_manager import ConfigManager
|
||||
# from videoarchiver.processor import progress_tracker # Import from processor package
|
||||
# from videoarchiver.processor.constants import REACTIONS
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import asyncio
|
||||
from typing import List, Optional, Dict, Any, Set, ClassVar
|
||||
from datetime import datetime
|
||||
|
||||
try:
|
||||
#try:
|
||||
# Try relative imports first
|
||||
from ..queue.types import QueuePriority, QueueMetrics, ProcessingMetrics
|
||||
from ..queue.models import QueueItem
|
||||
except ImportError:
|
||||
from ..queue.types import QueuePriority, QueueMetrics, ProcessingMetrics
|
||||
from ..queue.models import QueueItem
|
||||
#except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.queue.types import QueuePriority, QueueMetrics, ProcessingMetrics
|
||||
# from videoarchiver.queue.models import QueueItem
|
||||
|
||||
@@ -7,24 +7,25 @@ from typing import List, Optional
|
||||
import discord # type: ignore
|
||||
from urllib.parse import urlparse
|
||||
|
||||
try:
|
||||
# Try relative imports first
|
||||
from ..processor.constants import (
|
||||
REACTIONS,
|
||||
ReactionType,
|
||||
get_reaction,
|
||||
get_progress_emoji,
|
||||
)
|
||||
from ..database.video_archive_db import VideoArchiveDB
|
||||
except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.processor.constants import (
|
||||
REACTIONS,
|
||||
ReactionType,
|
||||
get_reaction,
|
||||
get_progress_emoji,
|
||||
)
|
||||
# from videoarchiver.database.video_archive_db import VideoArchiveDB
|
||||
# try:
|
||||
# Try relative imports first
|
||||
from ..processor.constants import (
|
||||
REACTIONS,
|
||||
ReactionType,
|
||||
get_reaction,
|
||||
get_progress_emoji,
|
||||
)
|
||||
from ..database.video_archive_db import VideoArchiveDB
|
||||
|
||||
# except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.processor.constants import (
|
||||
# REACTIONS,
|
||||
# ReactionType,
|
||||
# get_reaction,
|
||||
# get_progress_emoji,
|
||||
# )
|
||||
# from videoarchiver.database.video_archive_db import VideoArchiveDB
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
|
||||
@@ -18,12 +18,13 @@ from typing import (
|
||||
)
|
||||
import discord # type: ignore
|
||||
|
||||
try:
|
||||
# Try relative imports first
|
||||
from ..utils.exceptions import DisplayError
|
||||
except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.utils.exceptions import DisplayError
|
||||
# try:
|
||||
# Try relative imports first
|
||||
from ..utils.exceptions import DisplayError
|
||||
|
||||
# except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
# from videoarchiver.utils.exceptions import DisplayError
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user