]> www.vanbest.org Git - motioneye-debian/commitdiff
fixed thread_id_to_camera_id()
authorCalin Crisan <ccrisan@gmail.com>
Sat, 21 Nov 2015 20:22:00 +0000 (22:22 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 21 Nov 2015 20:22:00 +0000 (22:22 +0200)
motioneye/handlers.py
motioneye/motionctl.py

index fa11e95c54e27a12b2597921d3bee2d28024842a..edfb390bc72e2061a0ef3be5d965ea5cbe81e4d9 100644 (file)
@@ -1396,12 +1396,15 @@ class RelayEventHandler(BaseHandler):
     def post(self):
         event = self.get_argument('event')
         thread_id = int(self.get_argument('thread_id'))
-        logging.debug('recevied relayed event %(event)s for thread id %(id)s' % {'event': event, 'id': thread_id})
-        
+
         camera_id = motionctl.thread_id_to_camera_id(thread_id)
         if camera_id is None:
             logging.debug('ignoring event for unknown thread id %s' % thread_id)
             return self.finish_json()
+
+        else:
+            logging.debug('recevied relayed event %(event)s for thread id %(id)s (camera id %(cid)s)' % {
+                    'event': event, 'id': thread_id, 'cid': camera_id})
         
         camera_config = config.get_camera(camera_id)
         if not utils.local_motion_camera(camera_config):
index 9c7116c525bec76c9cb7b8f1b4bd9bb1f2351892..f3c6c7c2903bc0e19910209af4de026931a082e4 100644 (file)
@@ -299,18 +299,10 @@ def camera_id_to_thread_id(camera_id):
     
 
 def thread_id_to_camera_id(thread_id):
-    # find the corresponding camera_id
-    # (which can be different from thread_id)
-    camera_ids = config.get_camera_ids()
-    tid = 0
-    for cid in camera_ids:
-        camera_config = config.get_camera(cid)
-        if utils.local_motion_camera(camera_config):
-            tid += 1
-            if tid == thread_id:
-                return cid
-    
-    return None
+    main_config = config.get_main()
+    threads = main_config.get('thread', '')
+
+    return int(re.search('thread-(\d+).conf', threads[thread_id - 1]).group(1))
 
 
 def _disable_initial_motion_detection():