diff --git a/frigate/detectors/plugins/openvino.py b/frigate/detectors/plugins/openvino.py index 3b65e5c29..3592cb7db 100644 --- a/frigate/detectors/plugins/openvino.py +++ b/frigate/detectors/plugins/openvino.py @@ -41,7 +41,7 @@ class OvDetector(DetectionApi): tensor_shape = self.interpreter.output(self.output_indexes).shape logger.info(f"Model Output-{self.output_indexes} Shape: {tensor_shape}") self.output_indexes += 1 - except: + except Exception: logger.info(f"Model has {self.output_indexes} Output Tensors") break if self.ov_model_type == ModelTypeEnum.yolox: diff --git a/frigate/http.py b/frigate/http.py index 7abaa805b..dd3ddfd76 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -488,7 +488,7 @@ def event_thumbnail(id, max_cache_age=2592000): tracked_obj = camera_state.tracked_objects.get(id) if tracked_obj is not None: thumbnail_bytes = tracked_obj.get_thumbnail() - except: + except Exception: return "Event not found", 404 if thumbnail_bytes is None: @@ -617,9 +617,9 @@ def event_snapshot(id): height=request.args.get("h", type=int), quality=request.args.get("quality", default=70, type=int), ) - except: + except Exception: return "Event not found", 404 - except: + except Exception: return "Event not found", 404 if jpg_bytes is None: @@ -894,7 +894,7 @@ def create_event(camera_name, label): def end_event(event_id): try: current_app.external_processor.finish_manual_event(event_id) - except: + except Exception: return jsonify( {"success": False, "message": f"{event_id} must be set and valid."}, 404 ) diff --git a/frigate/output.py b/frigate/output.py index 323613e43..1a394d79f 100644 --- a/frigate/output.py +++ b/frigate/output.py @@ -148,7 +148,7 @@ class BroadcastThread(threading.Thread): ): try: ws.send(buf, binary=True) - except: + except ValueError: pass elif self.converter.process.poll() is not None: break diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py index fc8a00d8b..522da48d8 100644 --- a/frigate/record/maintainer.py +++ b/frigate/record/maintainer.py @@ -63,7 +63,7 @@ class RecordingMaintainer(threading.Thread): for nt in flist: if nt.path.startswith(CACHE_DIR): files_in_use.append(nt.path.split("/")[-1]) - except: + except psutil.Error: continue # group recordings by camera diff --git a/frigate/stats.py b/frigate/stats.py index 3f042cf4a..3359a7602 100644 --- a/frigate/stats.py +++ b/frigate/stats.py @@ -9,6 +9,7 @@ import os import requests from typing import Optional, Any from multiprocessing.synchronize import Event as MpEvent +from requests.exceptions import RequestException from frigate.comms.dispatcher import Dispatcher from frigate.config import FrigateConfig @@ -31,7 +32,7 @@ def get_latest_version(config: FrigateConfig) -> str: "https://api.github.com/repos/blakeblackshear/frigate/releases/latest", timeout=10, ) - except: + except RequestException: return "unknown" response = request.json() diff --git a/frigate/util.py b/frigate/util.py index 53d85bf9a..2f93fefa0 100755 --- a/frigate/util.py +++ b/frigate/util.py @@ -839,7 +839,7 @@ def get_cpu_stats() -> dict[str, dict]: "mem": f"{mem_pct}", "cmdline": " ".join(cmdline), } - except: + except Exception: continue return usages @@ -870,7 +870,7 @@ def get_bandwidth_stats() -> dict[str, dict]: usages[process[len(process) - 2]] = { "bandwidth": round(float(stats[1]) + float(stats[2]), 1), } - except: + except (IndexError, ValueError): continue return usages @@ -990,11 +990,11 @@ def get_nvidia_gpu_stats() -> dict[int, dict]: "gpu": gpu_util, "mem": gpu_mem_util, } - except: + except Exception: + pass + finally: return results - return results - def ffprobe_stream(path: str) -> sp.CompletedProcess: """Run ffprobe on stream."""