]> www.vanbest.org Git - motioneye-debian/commitdiff
fixed wrong camera/thread_id association when sending emails
authorCalin Crisan <ccrisan@gmail.com>
Sun, 20 Dec 2015 16:26:58 +0000 (18:26 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Sun, 20 Dec 2015 16:26:58 +0000 (18:26 +0200)
motioneye/motionctl.py
motioneye/sendmail.py

index 82f4f7e0e432c64e30f3ff8e65edbe7193c74e08..741294a86e69d9d9e27755142d0df36df73ef575 100644 (file)
@@ -293,6 +293,7 @@ def camera_id_to_thread_id(camera_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.local_motion_camera(camera_config):
@@ -309,7 +310,7 @@ def thread_id_to_camera_id(thread_id):
     threads = main_config.get('thread', '')
 
     try:
-        return int(re.search('thread-(\d+).conf', threads[thread_id - 1]).group(1))
+        return int(re.search('thread-(\d+).conf', threads[int(thread_id) - 1]).group(1))
     
     except IndexError:
         return None
index 19c3a697794513a4d9e5c1e3c907ceda01b8f961..59efe64fcee58514baaf67ee6c8c6e98e2019c71 100644 (file)
@@ -35,6 +35,7 @@ import settings
 
 import config
 import mediafiles
+import motionctl
 import tzctl
 
 
@@ -140,7 +141,7 @@ def parse_options(parser, args):
     parser.add_argument('tls', help='"true" to use TLS')
     parser.add_argument('to', help='the email recipient(s)')
     parser.add_argument('msg_id', help='the identifier of the message')
-    parser.add_argument('camera_id', help='the id of the camera')
+    parser.add_argument('thread_id', help='the id of the motion thread')
     parser.add_argument('moment', help='the moment in ISO-8601 format')
     parser.add_argument('timespan', help='picture collection time span')
 
@@ -172,6 +173,8 @@ def main(parser, args):
     # email notifications are critical
     settings.LIST_MEDIA_TIMEOUT = 10
     
+    camera_id = motionctl.thread_id_to_camera_id(options.thread_id)
+
     logging.debug('server = %s' % options.server)
     logging.debug('port = %s' % options.port)
     logging.debug('account = %s' % options.account)
@@ -180,7 +183,8 @@ def main(parser, args):
     logging.debug('tls = %s' % str(options.tls).lower())
     logging.debug('to = %s' % options.to)
     logging.debug('msg_id = %s' % options.msg_id)
-    logging.debug('camera_id = %s' % options.camera_id)
+    logging.debug('thread_id = %s' % options.thread_id)
+    logging.debug('camera_id = %s' % camera_id)
     logging.debug('moment = %s' % options.moment.strftime('%Y-%m-%d %H:%M:%S'))
     logging.debug('smtp timeout = %d' % settings.SMTP_TIMEOUT)
     logging.debug('timespan = %d' % options.timespan)
@@ -199,4 +203,4 @@ def main(parser, args):
 
         logging.debug('bye!')
     
-    make_message(subject, message, options.camera_id, options.moment, options.timespan, on_message)
+    make_message(subject, message, camera_id, options.moment, options.timespan, on_message)