Simplify plus creation

This commit is contained in:
Nick Mowen 2022-06-14 12:42:52 -06:00
parent c341e2b46c
commit 614fda5cd9

View File

@ -48,18 +48,12 @@ class FrigateApp:
self.detection_out_events: dict[str, Event] = {} self.detection_out_events: dict[str, Event] = {}
self.detection_shms: list[mp.shared_memory.SharedMemory] = [] self.detection_shms: list[mp.shared_memory.SharedMemory] = []
self.log_queue: Queue = mp.Queue() self.log_queue: Queue = mp.Queue()
self.plus_api = PlusApi()
self.camera_metrics: dict[str, CameraMetricsTypes] = {} self.camera_metrics: dict[str, CameraMetricsTypes] = {}
def set_environment_vars(self) -> None: def set_environment_vars(self) -> None:
for key, value in self.config.environment_vars.items(): for key, value in self.config.environment_vars.items():
os.environ[key] = value os.environ[key] = value
# plus needs to be re-created if API KEY
# is included in config env vars
if key == PLUS_ENV_VAR:
self.plus_api = PlusApi()
def ensure_dirs(self) -> None: def ensure_dirs(self) -> None:
for d in [RECORD_DIR, CLIPS_DIR, CACHE_DIR]: for d in [RECORD_DIR, CLIPS_DIR, CACHE_DIR]:
if not os.path.exists(d) and not os.path.islink(d): if not os.path.exists(d) and not os.path.islink(d):
@ -176,6 +170,9 @@ class FrigateApp:
) )
self.mqtt_relay.start() self.mqtt_relay.start()
def init_plus(self) -> None:
self.plus_api = PlusApi()
def start_detectors(self) -> None: def start_detectors(self) -> None:
model_path = self.config.model.path model_path = self.config.model.path
model_shape = (self.config.model.height, self.config.model.width) model_shape = (self.config.model.height, self.config.model.width)
@ -352,6 +349,7 @@ class FrigateApp:
self.init_queues() self.init_queues()
self.init_database() self.init_database()
self.init_mqtt() self.init_mqtt()
self.init_plus()
except Exception as e: except Exception as e:
print(e) print(e)
self.log_process.terminate() self.log_process.terminate()