-> 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
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
STATIC_URL = '/static/'
LISTEN = '0.0.0.0'
-PORT = 8765
\ No newline at end of file
+PORT = 8765
+
+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