]> www.vanbest.org Git - motioneye-debian/commitdiff
added some motionctl code
authorCalin Crisan <ccrisan@gmail.com>
Sat, 28 Sep 2013 16:58:30 +0000 (19:58 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 28 Sep 2013 16:58:30 +0000 (19:58 +0300)
doc/todo.txt
settings.py
src/motionctl.py

index 2ff1d97d5e0b935d2d9ff2da6f89a15f1d43268e..625387c5aa5dc4ab47e70b488d9fc31ce980d0d1 100644 (file)
@@ -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
index 4740e584748878d3d3e338021be738d4b236cc53..1278a2a345ecdd70c2e570db798f73bf0c804fd6 100644 (file)
@@ -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
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..69d3082623e1dace174bc6a5bafa2044eb1a6072 100644 (file)
@@ -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