mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-12 01:39:25 +02:00
fix: Use absolute paths for debug_dumps directory
- Changed debug_dumps path from relative to absolute (/app/debug_dumps) - Updated direct_search_service.py to use consistent absolute path - Updated debug.py router to use the same absolute path - Added debug_dumps directory creation in Dockerfile - Improved _dump_debug_html with safer filename handling
This commit is contained in:
3 files changed
+21
-8
No files matched your search
+2
-2
@@ -37,8 +37,8 @@ RUN chmod +x docker-entrypoint.sh
|
||||
# Copy built frontend static files
|
||||
COPY --from=frontend-build /app/frontend/dist /app/static
|
||||
|
||||
# Create screenshots directory
|
||||
RUN mkdir -p screenshots
|
||||
# Create screenshots and debug_dumps directories
|
||||
RUN mkdir -p screenshots debug_dumps
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8555
|
||||
|
||||
@@ -18,7 +18,8 @@ router = APIRouter(
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
DEBUG_DIR = "debug_dumps"
|
||||
# Chemin absolu pour les dumps de débogage (doit correspondre à celui dans direct_search_service.py)
|
||||
DEBUG_DIR = "/app/debug_dumps"
|
||||
|
||||
class DebugFile(BaseModel):
|
||||
filename: str
|
||||
|
||||
@@ -7,6 +7,7 @@ import asyncio
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from urllib.parse import quote_plus, urljoin, urlparse
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
@@ -25,19 +26,30 @@ USER_AGENT = (
|
||||
)
|
||||
|
||||
|
||||
# Chemin absolu pour les dumps de débogage (doit correspondre à celui dans debug.py)
|
||||
DEBUG_DUMPS_DIR = "/app/debug_dumps"
|
||||
|
||||
|
||||
def _dump_debug_html(html: str, domain: str, query: str):
|
||||
"""Sauvegarde le HTML pour débogage"""
|
||||
try:
|
||||
debug_dir = "debug_dumps"
|
||||
if not os.path.exists(debug_dir):
|
||||
os.makedirs(debug_dir)
|
||||
|
||||
filename = f"{debug_dir}/{domain}_{query}_{int(asyncio.get_event_loop().time())}.html"
|
||||
if not os.path.exists(DEBUG_DUMPS_DIR):
|
||||
os.makedirs(DEBUG_DUMPS_DIR, exist_ok=True)
|
||||
logger.info(f"Created debug dumps directory: {DEBUG_DUMPS_DIR}")
|
||||
|
||||
# Utiliser un timestamp unique basé sur le temps actuel
|
||||
timestamp = int(time.time() * 1000)
|
||||
# Nettoyer la query pour le nom de fichier
|
||||
safe_query = "".join(c if c.isalnum() else "_" for c in query)[:50]
|
||||
filename = f"{DEBUG_DUMPS_DIR}/{domain}_{safe_query}_{timestamp}.html"
|
||||
|
||||
with open(filename, "w", encoding="utf-8") as f:
|
||||
f.write(html)
|
||||
logger.info(f"HTML dump saved to {filename}")
|
||||
return filename
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to dump HTML: {e}")
|
||||
return None
|
||||
|
||||
|
||||
class SearchResult:
|
||||
|
||||
Reference in new issue
Block a user