treewide: fix bare except clauses

This commit is contained in:
Martin Weinelt 2023-05-23 02:57:35 +02:00
parent 2807a229a2
commit f525b9cf68
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759
6 changed files with 14 additions and 13 deletions

View File

@ -41,7 +41,7 @@ class OvDetector(DetectionApi):
tensor_shape = self.interpreter.output(self.output_indexes).shape tensor_shape = self.interpreter.output(self.output_indexes).shape
logger.info(f"Model Output-{self.output_indexes} Shape: {tensor_shape}") logger.info(f"Model Output-{self.output_indexes} Shape: {tensor_shape}")
self.output_indexes += 1 self.output_indexes += 1
except: except Exception:
logger.info(f"Model has {self.output_indexes} Output Tensors") logger.info(f"Model has {self.output_indexes} Output Tensors")
break break
if self.ov_model_type == ModelTypeEnum.yolox: if self.ov_model_type == ModelTypeEnum.yolox:

View File

@ -488,7 +488,7 @@ def event_thumbnail(id, max_cache_age=2592000):
tracked_obj = camera_state.tracked_objects.get(id) tracked_obj = camera_state.tracked_objects.get(id)
if tracked_obj is not None: if tracked_obj is not None:
thumbnail_bytes = tracked_obj.get_thumbnail() thumbnail_bytes = tracked_obj.get_thumbnail()
except: except Exception:
return "Event not found", 404 return "Event not found", 404
if thumbnail_bytes is None: if thumbnail_bytes is None:
@ -617,9 +617,9 @@ def event_snapshot(id):
height=request.args.get("h", type=int), height=request.args.get("h", type=int),
quality=request.args.get("quality", default=70, type=int), quality=request.args.get("quality", default=70, type=int),
) )
except: except Exception:
return "Event not found", 404 return "Event not found", 404
except: except Exception:
return "Event not found", 404 return "Event not found", 404
if jpg_bytes is None: if jpg_bytes is None:
@ -894,7 +894,7 @@ def create_event(camera_name, label):
def end_event(event_id): def end_event(event_id):
try: try:
current_app.external_processor.finish_manual_event(event_id) current_app.external_processor.finish_manual_event(event_id)
except: except Exception:
return jsonify( return jsonify(
{"success": False, "message": f"{event_id} must be set and valid."}, 404 {"success": False, "message": f"{event_id} must be set and valid."}, 404
) )

View File

@ -148,7 +148,7 @@ class BroadcastThread(threading.Thread):
): ):
try: try:
ws.send(buf, binary=True) ws.send(buf, binary=True)
except: except ValueError:
pass pass
elif self.converter.process.poll() is not None: elif self.converter.process.poll() is not None:
break break

View File

@ -63,7 +63,7 @@ class RecordingMaintainer(threading.Thread):
for nt in flist: for nt in flist:
if nt.path.startswith(CACHE_DIR): if nt.path.startswith(CACHE_DIR):
files_in_use.append(nt.path.split("/")[-1]) files_in_use.append(nt.path.split("/")[-1])
except: except psutil.Error:
continue continue
# group recordings by camera # group recordings by camera

View File

@ -9,6 +9,7 @@ import os
import requests import requests
from typing import Optional, Any from typing import Optional, Any
from multiprocessing.synchronize import Event as MpEvent from multiprocessing.synchronize import Event as MpEvent
from requests.exceptions import RequestException
from frigate.comms.dispatcher import Dispatcher from frigate.comms.dispatcher import Dispatcher
from frigate.config import FrigateConfig 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", "https://api.github.com/repos/blakeblackshear/frigate/releases/latest",
timeout=10, timeout=10,
) )
except: except RequestException:
return "unknown" return "unknown"
response = request.json() response = request.json()

View File

@ -839,7 +839,7 @@ def get_cpu_stats() -> dict[str, dict]:
"mem": f"{mem_pct}", "mem": f"{mem_pct}",
"cmdline": " ".join(cmdline), "cmdline": " ".join(cmdline),
} }
except: except Exception:
continue continue
return usages return usages
@ -870,7 +870,7 @@ def get_bandwidth_stats() -> dict[str, dict]:
usages[process[len(process) - 2]] = { usages[process[len(process) - 2]] = {
"bandwidth": round(float(stats[1]) + float(stats[2]), 1), "bandwidth": round(float(stats[1]) + float(stats[2]), 1),
} }
except: except (IndexError, ValueError):
continue continue
return usages return usages
@ -990,11 +990,11 @@ def get_nvidia_gpu_stats() -> dict[int, dict]:
"gpu": gpu_util, "gpu": gpu_util,
"mem": gpu_mem_util, "mem": gpu_mem_util,
} }
except: except Exception:
pass
finally:
return results return results
return results
def ffprobe_stream(path: str) -> sp.CompletedProcess: def ffprobe_stream(path: str) -> sp.CompletedProcess:
"""Run ffprobe on stream.""" """Run ffprobe on stream."""