From: Calin Crisan Date: Wed, 26 Oct 2016 17:49:40 +0000 (+0300) Subject: fixed wrong camera target for motion detection after enabling and disabling some... X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=eef55b4c24a02c7840f95faaf43c52276749eafb;p=motioneye-debian fixed wrong camera target for motion detection after enabling and disabling some cameras --- diff --git a/motioneye/motionctl.py b/motioneye/motionctl.py index 948e56b..2c2bef9 100644 --- a/motioneye/motionctl.py +++ b/motioneye/motionctl.py @@ -299,16 +299,16 @@ def camera_id_to_thread_id(camera_id): # find the corresponding thread_id # (which can be different from camera_id) - camera_ids = config.get_camera_ids() - thread_id = 0 - camera_id = int(camera_id) - for cid in camera_ids: - camera_config = config.get_camera(cid) - if utils.is_local_motion_camera(camera_config): - thread_id += 1 - if cid == camera_id: - return thread_id or None + main_config = config.get_main() + threads = main_config.get('thread', []) + + thread_filename = 'thread-%d.conf' % camera_id + for i, thread in enumerate(threads): + if thread != thread_filename: + continue + + return i + 1 return None @@ -317,7 +317,7 @@ def thread_id_to_camera_id(thread_id): import config main_config = config.get_main() - threads = main_config.get('thread', '') + threads = main_config.get('thread', []) try: return int(re.search('thread-(\d+).conf', threads[int(thread_id) - 1]).group(1))