aboutsummaryrefslogtreecommitdiff
path: root/client.py
diff options
context:
space:
mode:
authorFranoosh <uinarf@autistici.org>2026-06-18 07:23:18 +0200
committerFranoosh <uinarf@autistici.org>2026-06-18 07:23:18 +0200
commit82dfeb112ad01f9e677a252053f0f480134d9cf9 (patch)
tree85a0b4998110c3cf81fa7d7a254c2efe7ffaff55 /client.py
parent28150dd2c4d03ed844e8d1a5cfc463f5d1f9b45f (diff)
downloadZeroMQ_Video_Streaming-82dfeb112ad01f9e677a252053f0f480134d9cf9.tar.gz
ZeroMQ_Video_Streaming-82dfeb112ad01f9e677a252053f0f480134d9cf9.tar.bz2
ZeroMQ_Video_Streaming-82dfeb112ad01f9e677a252053f0f480134d9cf9.zip
webserver.py:HEADmaster
- fix parameter extraction in validate_ functions - fix logging statement missing a parameter. client.py: - cosmetic changes: change multiple returns to building retval - logging fixes.
Diffstat (limited to 'client.py')
-rw-r--r--client.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/client.py b/client.py
index 7b7a697..4a18d75 100644
--- a/client.py
+++ b/client.py
@@ -527,7 +527,7 @@ class ClientTask(Thread):
self.video_threads[camera_id].device_threshold = _value # <-- integer!
# configparser requires strings:
cfg.set('cameras', f"{camera_id.decode('utf-8')}.contour_size_threshold", str(value))
- logger.info("Modified contour size threshold of camera %r to %d.", camera_id, value)
+ logger.info("Modified contour size threshold of camera %r to %d.", camera_id, _value)
case b'modify_camera_grace_pd':
try:
_value = int(value)
@@ -537,7 +537,7 @@ class ClientTask(Thread):
CAMERAS[camera_id][b'movement_grace_period'] = _value # <-- integer!
self.video_threads[camera_id].device_grace_period = _value # <-- integer!
cfg.set('cameras', f"{camera_id.decode('utf-8')}.movement_grace_period", str(value))
- logger.info("Modified movement grace period of camera %r to %d.", camera_id, value)
+ logger.info("Modified movement grace period of camera %r to %d.", camera_id, _value)
case b'add_camera':
CAMERAS[camera_id] = {b'address': value}
# vid_cl = ClientVideo(camera_id, CAMERAS[camera_id], self.queue)
@@ -865,9 +865,10 @@ def validate_camera_address(address: str) -> bool:
True if address is valid, False otherwise
"""
# Check if address is an integer (device index):
+ retval = False
if address.startswith('/dev/video'):
- return True
- raise False
+ retval = True
+ return retval
def validate_camera_threshold(threshold: str) -> bool:
@@ -886,10 +887,12 @@ def validate_camera_threshold(threshold: str) -> bool:
"""
try:
if int(threshold) > 0:
- return True
+ retval = True
+ else:
+ retval = False
except ValueError:
- raise False
- return False
+ retval = False
+ return retval
def validate_camera_grace_pd(grace_pd: str) -> bool:
@@ -908,10 +911,12 @@ def validate_camera_grace_pd(grace_pd: str) -> bool:
"""
try:
if int(grace_pd) >= 0:
- return True
+ retval = True
+ else:
+ retval = False
except ValueError:
- return False
- return False
+ retval = False
+ return retval
def camera_address_unique(cfg: ConfigParser, address: str) -> bool:
@@ -930,14 +935,15 @@ def camera_address_unique(cfg: ConfigParser, address: str) -> bool:
bool
True if address is unique, False otherwise
"""
+ retval = True
for key, val in cfg.items('cameras'):
try:
_, param = key.split('.', 1)
if param == 'address' and val == address:
- return False
+ retval = False
except ValueError:
continue
- return True
+ return retval
def set_up_cameras(cameras_cfg_section: list[tuple[str, str]]) -> dict:
@@ -1015,16 +1021,17 @@ def get_serial_number() -> bytes:
bytes
Serial number as string
"""
+ serial = uuid.uuid4().hex.encode('utf-8') # Default to random uuid if we can't get serial
try:
with open('/proc/cpuinfo', 'r') as f:
for line in f:
if line.startswith('Serial'):
serial = line.split(':')[1].strip()
- return serial.encode('utf-8')
+ serial = serial.encode('utf-8')
except Exception as exc:
- logger.error("Error getting serial number: %r, using uuid.", exc)
+ logger.warning("Error getting serial number: %r, using uuid.", exc)
- return str(uuid.getnode()).encode('utf-8')
+ return serial
if __name__ == "__main__":