From: Calin Crisan Date: Sat, 28 Sep 2013 16:58:30 +0000 (+0300) Subject: added some motionctl code X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=eed1f48596585995b422c19acf069a9e1e3c227d;p=motioneye-debian added some motionctl code --- diff --git a/doc/todo.txt b/doc/todo.txt index 2ff1d97..625387c 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -1,4 +1,5 @@ -> group @config rules to top +-> motion conf and run dirs should be configurable in settings -> browser compatibility test -> requirements test -> hint text next to section titles diff --git a/settings.py b/settings.py index 4740e58..1278a2a 100644 --- a/settings.py +++ b/settings.py @@ -5,6 +5,8 @@ import sys PROJECT_PATH = os.path.dirname(sys.argv[0]) +CONF_PATH = os.path.join(PROJECT_PATH, 'conf') # TODO use this +RUN_PATH = PROJECT_PATH DEBUG = True LOG_LEVEL = logging.DEBUG @@ -15,4 +17,4 @@ STATIC_PATH = os.path.join(PROJECT_PATH, 'static') STATIC_URL = '/static/' LISTEN = '0.0.0.0' -PORT = 8765 \ No newline at end of file +PORT = 8765 diff --git a/src/motionctl.py b/src/motionctl.py index e69de29..69d3082 100644 --- a/src/motionctl.py +++ b/src/motionctl.py @@ -0,0 +1,40 @@ + +import os.path +import subprocess + +import settings + + +def find_program(): + try: + return subprocess.check_output('which motion', shell=True) + + except subprocess.CalledProcessError: # not found + return None + + +def start(): + program = find_program() + if not program: + raise Exception('motion executable could not be found') + + motion_config_path = os.path.join(settings.PROJECT_PATH, 'conf', 'motion.conf') # TODO conf path should be configurable + motion_log_path = os.path.join(settings.RUN_PATH, 'motion.log') + motion_pid_path = os.path.join(settings.RUN_PATH, 'motion.pid') + + args = [program, + '-c', motion_config_path, + '-n', + '-p', motion_pid_path] + + log_file = open(motion_log_path, 'w') + + subprocess.Popen(args, stdout=log_file, stderr=log_file) + + +def stop(): + pass + + +def running(): + pass