]> www.vanbest.org Git - motioneye-debian/commitdiff
fixed wrong camera target for motion detection after enabling and disabling some...
authorCalin Crisan <ccrisan@gmail.com>
Wed, 26 Oct 2016 17:49:40 +0000 (20:49 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Wed, 26 Oct 2016 17:49:40 +0000 (20:49 +0300)
motioneye/motionctl.py

index 948e56b86b0ca421531e85f874d473268ecb8a84..2c2bef96823ab63fbe4b494fbd567ba3b8f90596 100644 (file)
@@ -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))