mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-19 15:54:27 +02:00
Remove 30 redundant function-level imports
These modules were already imported at the top of each file. Removes re-imports of re, json, zipfile, and logging from inside functions in archive.py, library.py, main.py, printers.py, support.py, and test_library_api.py. Resolves all 30 CodeQL py/repeated-import findings.
This commit is contained in:
@@ -851,7 +851,6 @@ async def extract_zip_file(
|
||||
generate_stl_thumbnails: If True, generate thumbnails for STL files
|
||||
"""
|
||||
import tempfile
|
||||
import zipfile
|
||||
|
||||
if not file.filename or not file.filename.lower().endswith(".zip"):
|
||||
raise HTTPException(status_code=400, detail="Only ZIP files are supported")
|
||||
@@ -1313,8 +1312,6 @@ async def get_library_file_plates(
|
||||
and filament requirements. For single-plate exports, returns a single plate.
|
||||
"""
|
||||
import json
|
||||
import re
|
||||
import zipfile
|
||||
|
||||
import defusedxml.ElementTree as ET
|
||||
|
||||
@@ -1574,8 +1571,6 @@ async def get_library_file_plate_thumbnail(
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Get the thumbnail image for a specific plate from a library file."""
|
||||
import zipfile
|
||||
|
||||
from starlette.responses import Response
|
||||
|
||||
result = await db.execute(select(LibraryFile).where(LibraryFile.id == file_id))
|
||||
@@ -1616,8 +1611,6 @@ async def get_library_file_filament_requirements(
|
||||
file_id: The library file ID
|
||||
plate_id: Optional plate index to get filaments for a specific plate
|
||||
"""
|
||||
import zipfile
|
||||
|
||||
import defusedxml.ElementTree as ET
|
||||
|
||||
# Get the library file
|
||||
@@ -1746,8 +1739,6 @@ async def print_library_file(
|
||||
|
||||
Only sliced files (.gcode or .gcode.3mf) can be printed.
|
||||
"""
|
||||
import zipfile
|
||||
|
||||
from backend.app.main import register_expected_print
|
||||
from backend.app.models.printer import Printer
|
||||
from backend.app.services.bambu_ftp import (
|
||||
@@ -2188,8 +2179,6 @@ async def get_gcode(
|
||||
return FastAPIFileResponse(str(abs_path), media_type="text/plain")
|
||||
elif file.file_type == "3mf":
|
||||
# Extract gcode from 3mf
|
||||
import zipfile
|
||||
|
||||
try:
|
||||
with zipfile.ZipFile(str(abs_path), "r") as zf:
|
||||
# Find gcode file
|
||||
|
||||
@@ -852,7 +852,6 @@ async def get_printer_file_plates(
|
||||
"""Get available plates from a multi-plate 3MF file stored on a printer."""
|
||||
import io
|
||||
import json
|
||||
import zipfile
|
||||
|
||||
import defusedxml.ElementTree as ET
|
||||
|
||||
@@ -1097,7 +1096,6 @@ async def get_printer_file_plate_thumbnail(
|
||||
):
|
||||
"""Get a plate thumbnail image from a printer-stored 3MF file."""
|
||||
import io
|
||||
import zipfile
|
||||
|
||||
result = await db.execute(select(Printer).where(Printer.id == printer_id))
|
||||
printer = result.scalar_one_or_none()
|
||||
@@ -1594,8 +1592,6 @@ async def configure_ams_slot(
|
||||
kprofile_filament_id: K profile's filament_id for proper K profile linking
|
||||
k_value: Direct K value to set (0.0 to skip direct K value setting)
|
||||
"""
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info("[configure_ams_slot] printer_id=%s, ams_id=%s, tray_id=%s", printer_id, ams_id, tray_id)
|
||||
logger.info(
|
||||
|
||||
@@ -413,8 +413,6 @@ async def _collect_support_info() -> dict:
|
||||
|
||||
def _sanitize_log_content(content: str) -> str:
|
||||
"""Remove sensitive data from log content."""
|
||||
import re
|
||||
|
||||
# Replace IP addresses with [IP]
|
||||
content = re.sub(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b", "[IP]", content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user