Add module logger + surface silent exceptions in 7 logger-less files — 12 sites
These files had silent `except Exception: pass` blocks but no module logger. Added `import logging` + `logger = logging.getLogger(__name__)` at the top of each, then replaced the silent excepts with `logger.debug(...)`. - core/replaygain.py — 4 sites (id3 txxx + vorbis + mp4 atom reads) - core/wishlist/presence.py — 3 sites (wishlist row parsing + queries) - core/runtime_state.py — 1 site (activity toast emit) - core/automation/signals.py — 1 site (collect known signals) - core/download_engine/rate_limit.py — 1 site (plugin rate_limit_policy) - api/system.py — 1 site (hydrabase status probe) - api/search.py — 1 site (hydrabase search) Refs #369
This commit is contained in:
parent
8dc9f79f97
commit
8219771304
7 changed files with 46 additions and 24 deletions
|
|
@ -2,10 +2,14 @@
|
||||||
Search endpoints — search external sources (Spotify, iTunes, Hydrabase).
|
Search endpoints — search external sources (Spotify, iTunes, Hydrabase).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from flask import request, current_app
|
from flask import request, current_app
|
||||||
from .auth import require_api_key
|
from .auth import require_api_key
|
||||||
from .helpers import api_success, api_error
|
from .helpers import api_success, api_error
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def register_routes(bp):
|
def register_routes(bp):
|
||||||
|
|
||||||
|
|
@ -38,8 +42,8 @@ def register_routes(bp):
|
||||||
if hydra_results:
|
if hydra_results:
|
||||||
tracks = [_serialize_track(t) for t in hydra_results]
|
tracks = [_serialize_track(t) for t in hydra_results]
|
||||||
return api_success({"tracks": tracks, "source": "hydrabase"})
|
return api_success({"tracks": tracks, "source": "hydrabase"})
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("hydrabase search failed: %s", e)
|
||||||
|
|
||||||
spotify = ctx.get("spotify_client")
|
spotify = ctx.get("spotify_client")
|
||||||
from core.metadata_service import get_primary_source, get_primary_client
|
from core.metadata_service import get_primary_source, get_primary_client
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,15 @@
|
||||||
System endpoints — status, activity feed, stats.
|
System endpoints — status, activity feed, stats.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from .auth import require_api_key
|
from .auth import require_api_key
|
||||||
from .helpers import api_success, api_error
|
from .helpers import api_success, api_error
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def register_routes(bp):
|
def register_routes(bp):
|
||||||
|
|
||||||
|
|
@ -35,8 +38,8 @@ def register_routes(bp):
|
||||||
try:
|
try:
|
||||||
ws, _ = hydrabase.get_ws_and_lock()
|
ws, _ = hydrabase.get_ws_and_lock()
|
||||||
hydrabase_ok = ws is not None and ws.connected
|
hydrabase_ok = ws is not None and ws.connected
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("hydrabase status probe failed: %s", e)
|
||||||
|
|
||||||
return api_success({
|
return api_success({
|
||||||
"uptime": f"{hours}h {minutes}m {seconds}s",
|
"uptime": f"{hours}h {minutes}m {seconds}s",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ names from the saved automation set so the builder UI can autocomplete.
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def collect_known_signals(database) -> list[str]:
|
def collect_known_signals(database) -> list[str]:
|
||||||
|
|
@ -38,6 +41,6 @@ def collect_known_signals(database) -> list[str]:
|
||||||
signals.add(sig)
|
signals.add(sig)
|
||||||
except (json.JSONDecodeError, TypeError):
|
except (json.JSONDecodeError, TypeError):
|
||||||
pass
|
pass
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("collect known signals failed: %s", e)
|
||||||
return sorted(signals)
|
return sorted(signals)
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,11 @@ module-level constant in the client file.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class RateLimitPolicy:
|
class RateLimitPolicy:
|
||||||
|
|
@ -63,8 +66,8 @@ def resolve_policy(plugin) -> RateLimitPolicy:
|
||||||
policy = method()
|
policy = method()
|
||||||
if isinstance(policy, RateLimitPolicy):
|
if isinstance(policy, RateLimitPolicy):
|
||||||
return policy
|
return policy
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("plugin rate_limit_policy() call failed: %s", e)
|
||||||
|
|
||||||
declared = getattr(plugin, 'RATE_LIMIT_POLICY', None)
|
declared = getattr(plugin, 'RATE_LIMIT_POLICY', None)
|
||||||
if isinstance(declared, RateLimitPolicy):
|
if isinstance(declared, RateLimitPolicy):
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,13 @@ Tag writing uses mutagen directly to stay consistent with the rest of the codeba
|
||||||
Supported formats: MP3, FLAC, OGG Vorbis, Opus, M4A/MP4
|
Supported formats: MP3, FLAC, OGG Vorbis, Opus, M4A/MP4
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import Optional, Tuple, Dict
|
from typing import Optional, Tuple, Dict
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# ReplayGain 2.0 reference level (EBU R128)
|
# ReplayGain 2.0 reference level (EBU R128)
|
||||||
RG_REFERENCE_LUFS = -18.0
|
RG_REFERENCE_LUFS = -18.0
|
||||||
|
|
||||||
|
|
@ -189,8 +192,8 @@ def read_replaygain_tags(file_path: str) -> Dict[str, Optional[str]]:
|
||||||
result['track_peak'] = _mp4_rg(audio, _TAG_TRACK_PEAK)
|
result['track_peak'] = _mp4_rg(audio, _TAG_TRACK_PEAK)
|
||||||
result['album_gain'] = _mp4_rg(audio, _TAG_ALBUM_GAIN)
|
result['album_gain'] = _mp4_rg(audio, _TAG_ALBUM_GAIN)
|
||||||
result['album_peak'] = _mp4_rg(audio, _TAG_ALBUM_PEAK)
|
result['album_peak'] = _mp4_rg(audio, _TAG_ALBUM_PEAK)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("read replaygain tags failed: %s", e)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
@ -207,8 +210,8 @@ def _read_id3_txxx(audio, description: str) -> Optional[str]:
|
||||||
if frame_key.upper() == key.upper():
|
if frame_key.upper() == key.upper():
|
||||||
frame = audio.tags[frame_key]
|
frame = audio.tags[frame_key]
|
||||||
return str(frame.text[0]) if frame.text else None
|
return str(frame.text[0]) if frame.text else None
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("read id3 txxx frame failed: %s", e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -218,8 +221,8 @@ def _vorbis_first(audio, key: str) -> Optional[str]:
|
||||||
vals = audio.get(key) or audio.get(key.upper())
|
vals = audio.get(key) or audio.get(key.upper())
|
||||||
if vals:
|
if vals:
|
||||||
return str(vals[0])
|
return str(vals[0])
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("read vorbis comment failed: %s", e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -234,8 +237,8 @@ def _mp4_rg(audio, tag_name: str) -> Optional[str]:
|
||||||
if hasattr(val, 'decode'):
|
if hasattr(val, 'decode'):
|
||||||
return val.decode('utf-8')
|
return val.decode('utf-8')
|
||||||
return str(val)
|
return str(val)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("read mp4 replaygain atom failed: %s", e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
matched_context_lock = threading.Lock()
|
matched_context_lock = threading.Lock()
|
||||||
matched_downloads_context: Dict[str, Dict[str, Any]] = {}
|
matched_downloads_context: Dict[str, Dict[str, Any]] = {}
|
||||||
tasks_lock = threading.Lock()
|
tasks_lock = threading.Lock()
|
||||||
|
|
@ -57,8 +60,8 @@ def add_activity_item(icon, title, subtitle, time_ago="Now", show_toast=True):
|
||||||
if show_toast and _activity_toast_emitter is not None:
|
if show_toast and _activity_toast_emitter is not None:
|
||||||
try:
|
try:
|
||||||
_activity_toast_emitter("dashboard:toast", activity_item)
|
_activity_toast_emitter("dashboard:toast", activity_item)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("emit activity toast failed: %s", e)
|
||||||
|
|
||||||
return activity_item
|
return activity_item
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def load_wishlist_keys(cursor, profile_id: int) -> set[str]:
|
def load_wishlist_keys(cursor, profile_id: int) -> set[str]:
|
||||||
|
|
@ -27,21 +30,21 @@ def load_wishlist_keys(cursor, profile_id: int) -> set[str]:
|
||||||
wa = ""
|
wa = ""
|
||||||
if wname:
|
if wname:
|
||||||
keys.add(wname + "|||" + wa.lower().strip())
|
keys.add(wname + "|||" + wa.lower().strip())
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("parse wishlist row failed: %s", e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute("SELECT spotify_data FROM wishlist_tracks WHERE profile_id = ?", (profile_id,))
|
cursor.execute("SELECT spotify_data FROM wishlist_tracks WHERE profile_id = ?", (profile_id,))
|
||||||
_absorb(cursor.fetchall())
|
_absorb(cursor.fetchall())
|
||||||
return keys
|
return keys
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("profile-aware wishlist query failed: %s", e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute("SELECT spotify_data FROM wishlist_tracks")
|
cursor.execute("SELECT spotify_data FROM wishlist_tracks")
|
||||||
_absorb(cursor.fetchall())
|
_absorb(cursor.fetchall())
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.debug("legacy wishlist query failed: %s", e)
|
||||||
return keys
|
return keys
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue