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
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:

View File

@ -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
)

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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,9 +990,9 @@ def get_nvidia_gpu_stats() -> dict[int, dict]:
"gpu": gpu_util,
"mem": gpu_mem_util,
}
except:
return results
except Exception:
pass
finally:
return results