Format changes with Black

This commit is contained in:
Chris OBryan 2023-06-08 14:26:55 -05:00
parent 8390f054ac
commit 21f00b3858
3 changed files with 8 additions and 7 deletions

View File

@ -98,14 +98,14 @@ class Dispatcher:
def _on_capture_command(self, camera_name: str, payload: str) -> None:
"""Callback for detect topic."""
logger.info(f"Received capture command [{payload}] for [{camera_name}]")
capture_proc = self.camera_metrics[camera_name]['capture_process']
capture_proc = self.camera_metrics[camera_name]["capture_process"]
# Send SIGUSR1 to resume, SIGUSR2 to pause
new_state = True if payload == "ON" else False if payload == "OFF" else None
if new_state is not None:
sig = signal.SIGUSR1 if new_state else signal.SIGUSR2
self.config.cameras[camera_name].capture_enabled = new_state
os.kill( capture_proc.pid, sig )
os.kill(capture_proc.pid, sig)
self.publish(f"{camera_name}/capture/state", payload, retain=True)
def _on_detect_command(self, camera_name: str, payload: str) -> None:

View File

@ -641,7 +641,7 @@ def terminate_process(
proc: sp.Popen, logger_inst: logging.Logger = None, timeout: float = 30.0
):
logger_inst = logger_inst or logger
if proc is not None and proc.poll() == None:
if proc is not None and proc.poll() is None:
proc_name: str = proc.args[0]
logger_inst.info(f"Terminating the existing {proc_name} process...")
proc.terminate()

View File

@ -113,10 +113,11 @@ def create_tensor_input(frame, model_config, region):
# Expand dimensions since the model expects images to have shape: [1, height, width, 3]
return np.expand_dims(cropped_frame, axis=0)
def start_or_restart_ffmpeg(
ffmpeg_cmd, logger, logpipe: LogPipe, frame_size=None, ffmpeg_process=None
):
terminate_process( ffmpeg_process, logger_inst=logger )
terminate_process(ffmpeg_process, logger_inst=logger)
if frame_size is None:
process = sp.Popen(
@ -386,7 +387,7 @@ def capture_camera(name, config: CameraConfig, process_info):
def receiveSignal(signalNumber, frame):
logger.info(f"{name} Received signal {signalNumber}")
sig_queue.put( signalNumber )
sig_queue.put(signalNumber)
if signalNumber in (stop_sigs + pause_sigs):
stop_event.set()
@ -407,7 +408,7 @@ def capture_camera(name, config: CameraConfig, process_info):
# Pause here until stopped or resumed
while not sig_queue.empty() or prev_sig not in resume_sigs:
# Abort on a STOP signal
if( prev_sig := sig_queue.get() ) in stop_sigs:
if (prev_sig := sig_queue.get()) in stop_sigs:
break
logger.info(f"{name}: capture starting")