From 38cfedda41ddd48df223d4ec0f4b0f583e240883 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 6 Oct 2013 12:55:07 +0300 Subject: [PATCH] added a motion running checker --- doc/todo.txt | 1 - motioneye.py | 14 +++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/todo.txt b/doc/todo.txt index 5a092c5..4219faa 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -1,5 +1,4 @@ -> add a motion running status indicator (and maybe a start/stop button) --> add a timeout checker to check the running status of motion -> better ajax error handling -> add a messaging mechanism diff --git a/motioneye.py b/motioneye.py index 995ec57..88570b8 100755 --- a/motioneye.py +++ b/motioneye.py @@ -1,5 +1,6 @@ #!/usr/bin/env python2 +import datetime import inspect import logging import os.path @@ -126,9 +127,16 @@ def _start_motion(): import config import motionctl - if not motionctl.running() and config.has_enabled_cameras(): - motionctl.start() - logging.info('motion started') + # add a motion running checker + def checker(): + if not motionctl.running() and config.has_enabled_cameras(): + motionctl.start() + logging.info('motion started') + + ioloop = tornado.ioloop.IOLoop.instance() + ioloop.add_timeout(datetime.timedelta(seconds=10), checker) + + checker() if __name__ == '__main__': -- 2.39.5