mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-28 06:26:57 -05:00
Compare commits
1 Commits
pixeebot/d
...
pixeebot/d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec3974fa67 |
@@ -5,7 +5,6 @@ import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any, Optional
|
||||
from security import safe_command
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
@@ -167,7 +166,8 @@ class FFmpeg:
|
||||
"""Get FFmpeg version"""
|
||||
try:
|
||||
import subprocess
|
||||
result = safe_command.run(subprocess.run, [str(self.ffmpeg_path), "-version"],
|
||||
result = subprocess.run(
|
||||
[str(self.ffmpeg_path), "-version"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import os
|
||||
import logging
|
||||
import shutil
|
||||
import requests
|
||||
import tarfile
|
||||
import zipfile
|
||||
import subprocess
|
||||
@@ -19,7 +18,7 @@ import lzma
|
||||
# try:
|
||||
# Try relative imports first
|
||||
from exceptions import DownloadError
|
||||
from security import safe_command
|
||||
from security import safe_requests
|
||||
|
||||
# except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
@@ -176,7 +175,7 @@ class FFmpegDownloader:
|
||||
|
||||
logger.info(f"Downloading FFmpeg from {url}")
|
||||
try:
|
||||
response = requests.get(url, stream=True, timeout=30)
|
||||
response = safe_requests.get(url, stream=True, timeout=30)
|
||||
response.raise_for_status()
|
||||
|
||||
total_size = int(response.headers.get("content-length", 0))
|
||||
@@ -353,7 +352,8 @@ class FFmpegDownloader:
|
||||
|
||||
# Test FFmpeg functionality with enhanced error handling
|
||||
try:
|
||||
result = safe_command.run(subprocess.run, [str(self.ffmpeg_path), "-version"],
|
||||
result = subprocess.run(
|
||||
[str(self.ffmpeg_path), "-version"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
timeout=5,
|
||||
@@ -370,7 +370,8 @@ class FFmpegDownloader:
|
||||
|
||||
# Test FFprobe functionality with enhanced error handling
|
||||
try:
|
||||
result = safe_command.run(subprocess.run, [str(self.ffprobe_path), "-version"],
|
||||
result = subprocess.run(
|
||||
[str(self.ffprobe_path), "-version"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
timeout=5,
|
||||
|
||||
@@ -7,7 +7,6 @@ import platform
|
||||
import re
|
||||
from typing import Dict, List, Tuple
|
||||
from pathlib import Path
|
||||
from security import safe_command
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
@@ -77,7 +76,7 @@ class GPUDetector:
|
||||
try:
|
||||
# Use PowerShell to get GPU info
|
||||
cmd = ["powershell", "-Command", "Get-WmiObject Win32_VideoController | Select-Object Name"]
|
||||
result = safe_command.run(subprocess.run, cmd, capture_output=True, text=True, timeout=10)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
|
||||
|
||||
if result.returncode == 0:
|
||||
output = result.stdout.lower()
|
||||
@@ -154,7 +153,7 @@ class GPUDetector:
|
||||
|
||||
try:
|
||||
cmd = ["system_profiler", "SPDisplaysDataType"]
|
||||
result = safe_command.run(subprocess.run, cmd, capture_output=True, text=True, timeout=10)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
|
||||
|
||||
if result.returncode == 0:
|
||||
output = result.stdout.lower()
|
||||
@@ -174,7 +173,7 @@ class GPUDetector:
|
||||
try:
|
||||
# Check FFmpeg encoders
|
||||
cmd = [str(self.ffmpeg_path), "-hide_banner", "-encoders"]
|
||||
result = safe_command.run(subprocess.run, cmd, capture_output=True, text=True, timeout=10)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
|
||||
|
||||
if result.returncode == 0:
|
||||
output = result.stdout.lower()
|
||||
@@ -251,7 +250,7 @@ class GPUDetector:
|
||||
|
||||
elif system == "windows":
|
||||
cmd = ["powershell", "-Command", "Get-WmiObject Win32_VideoController | Select-Object Name"]
|
||||
result = safe_command.run(subprocess.run, cmd, capture_output=True, text=True, timeout=10)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
|
||||
|
||||
if result.returncode == 0:
|
||||
for line in result.stdout.splitlines():
|
||||
@@ -266,7 +265,7 @@ class GPUDetector:
|
||||
|
||||
elif system == "darwin":
|
||||
cmd = ["system_profiler", "SPDisplaysDataType"]
|
||||
result = safe_command.run(subprocess.run, cmd, capture_output=True, text=True, timeout=10)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
|
||||
|
||||
if result.returncode == 0:
|
||||
current_gpu = None
|
||||
|
||||
@@ -5,7 +5,6 @@ import psutil # type: ignore
|
||||
import subprocess
|
||||
import time
|
||||
from typing import Set, Optional
|
||||
from security import safe_command
|
||||
|
||||
logger = logging.getLogger("FFmpegProcessManager")
|
||||
|
||||
@@ -91,7 +90,8 @@ class ProcessManager:
|
||||
"""
|
||||
process = None
|
||||
try:
|
||||
process = safe_command.run(subprocess.Popen, command,
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True
|
||||
|
||||
@@ -9,7 +9,6 @@ from contextlib import contextmanager
|
||||
import tempfile
|
||||
import shutil
|
||||
import json
|
||||
from security import safe_command
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
@@ -127,7 +126,8 @@ class VideoAnalyzer:
|
||||
]
|
||||
|
||||
logger.debug(f"Running ffprobe command: {' '.join(cmd)}")
|
||||
result = safe_command.run(subprocess.run, cmd,
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
@@ -193,7 +193,8 @@ class VideoAnalyzer:
|
||||
]
|
||||
|
||||
logger.debug(f"Running dark scene analysis: {' '.join(sample_cmd)}")
|
||||
result = safe_command.run(subprocess.run, sample_cmd,
|
||||
result = subprocess.run(
|
||||
sample_cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=60 # Add timeout
|
||||
|
||||
@@ -11,7 +11,6 @@ from pathlib import Path
|
||||
|
||||
from utils.exceptions import VideoVerificationError
|
||||
from utils.file_deletion import SecureFileDeleter
|
||||
from security import safe_command
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
@@ -65,7 +64,8 @@ class FileOperations:
|
||||
file_path,
|
||||
]
|
||||
|
||||
result = safe_command.run(subprocess.run, cmd,
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
@@ -120,7 +120,7 @@ class FileOperations:
|
||||
"-show_format",
|
||||
file_path,
|
||||
]
|
||||
result = safe_command.run(subprocess.run, cmd, capture_output=True, text=True)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
raise Exception(f"FFprobe failed: {result.stderr}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user