]> www.vanbest.org Git - motioneye-debian/commitdiff
motion detection status detection improvements
authorCalin Crisan <ccrisan@gmail.com>
Mon, 1 Sep 2014 17:01:15 +0000 (20:01 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Mon, 1 Sep 2014 17:01:15 +0000 (20:01 +0300)
src/motionctl.py
src/wsswitch.py

index bb244dcafaa5e540635fac7c7fe9d00578020788..c738ce58355c9d71c401d7dab3213ae0c269bda6 100644 (file)
@@ -191,15 +191,18 @@ def get_motion_detection(camera_id):
     
     url = 'http://127.0.0.1:7999/%(id)s/detection/status' % {'id': thread_id}
     
-    request = HTTPRequest(url, connect_timeout=2, request_timeout=2)
+    request = HTTPRequest(url, connect_timeout=5, request_timeout=5)
     http_client = HTTPClient()
-    response = http_client.fetch(request)
-
-    if response.error:
+    try:
+        response = http_client.fetch(request)
+        if response.error:
+            raise response.error 
+    
+    except Exception as e:
         logging.error('failed to get motion detection status for camera with id %(id)s: %(msg)s' % {
                 'id': camera_id,
-                'msg': unicode(response.error)})
-        
+                'msg': unicode(e)})
+
         return None
     
     enabled = bool(response.body.lower().count('active'))
index b0e72cdc1ea5caa383ca2f2abfb5950f70d12d73..15364ffb52e41d4a8491489d799053cc30fd9dad 100644 (file)
@@ -97,6 +97,10 @@ def _check_ws():
         must_be_enabled = (now_during and working_schedule_type == 'during') or (not now_during and working_schedule_type == 'outside')
         
         currently_enabled = motionctl.get_motion_detection(camera_id)
+        if currently_enabled is None: # could not detect current status
+            logging.warn('skipping motion detection status update for camera with id %(id)s' % {'id': camera_id})
+            continue
+            
         if currently_enabled and not must_be_enabled:
             logging.debug('must disable motion detection for camera with id %(id)s (%(what)s working schedule)' % {
                     'id': camera_id,