From c7a1a6d5c71737e6a1217ec275801fc3034e5be7 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 26 Feb 2015 19:56:02 +0200 Subject: [PATCH] added support for custom motion binary setting --- motioneye.py | 1 + settings_default.py | 3 +++ src/motionctl.py | 20 +++++++++++++++----- src/wifictl.py | 5 ++++- static/js/main.js | 2 +- templates/main.html | 2 +- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/motioneye.py b/motioneye.py index 915ba8b..089e7e0 100755 --- a/motioneye.py +++ b/motioneye.py @@ -45,6 +45,7 @@ def _configure_settings(): set_default_setting('RUN_PATH', os.path.join(settings.PROJECT_PATH, 'run')) set_default_setting('LOG_PATH', os.path.join(settings.PROJECT_PATH, 'log')) set_default_setting('MEDIA_PATH', os.path.join(settings.PROJECT_PATH, 'media')) + set_default_setting('MOTION_BINARY', None) set_default_setting('REPO', None) set_default_setting('LOG_LEVEL', logging.INFO) set_default_setting('LISTEN', '0.0.0.0') diff --git a/settings_default.py b/settings_default.py index 948a337..50f708d 100644 --- a/settings_default.py +++ b/settings_default.py @@ -23,6 +23,9 @@ LOG_PATH = os.path.abspath(os.path.join(PROJECT_PATH, 'log')) # default output path for media files MEDIA_PATH = os.path.abspath(os.path.join(PROJECT_PATH, 'media')) +# path to motion binary (automatically detected if not set) +MOTION_BINARY = None + # repository details for software updating REPO = ('ccrisan', 'motioneye') diff --git a/src/motionctl.py b/src/motionctl.py index b55ea3a..c910b93 100644 --- a/src/motionctl.py +++ b/src/motionctl.py @@ -39,12 +39,20 @@ def find_motion(): global _motion_binary_cache if _motion_binary_cache: return _motion_binary_cache - - try: - binary = subprocess.check_output('which motion', shell=True).strip() - except subprocess.CalledProcessError: # not found - return None + if settings.MOTION_BINARY: + if os.path.exists(settings.MOTION_BINARY): + binary = settings.MOTION_BINARY + + else: + return None + + else: # autodetect motion binary path + try: + binary = subprocess.check_output('which motion', shell=True).strip() + + except subprocess.CalledProcessError: # not found + return None try: help = subprocess.check_output(binary + ' -h || true', shell=True) @@ -87,6 +95,8 @@ def start(): program, version = program # @UnusedVariable + logging.debug('using motion binary "%s"' % program) + motion_config_path = os.path.join(settings.CONF_PATH, 'motion.conf') motion_log_path = os.path.join(settings.LOG_PATH, 'motion.log') motion_pid_path = os.path.join(settings.RUN_PATH, 'motion.pid') diff --git a/src/wifictl.py b/src/wifictl.py index ad3f8e6..0890b43 100644 --- a/src/wifictl.py +++ b/src/wifictl.py @@ -89,7 +89,9 @@ def _get_wifi_settings(): def _set_wifi_settings(s): - # will update the first configured network + s.setdefault('wifiEnabled', False) + s.setdefault('wifiNetworkName', '') + s.setdefault('wifiNetworkKey', '') logging.debug('writing wifi settings to %s' % WPA_SUPPLICANT_CONF) @@ -97,6 +99,7 @@ def _set_wifi_settings(s): ssid = s['wifiNetworkName'] psk = s['wifiNetworkKey'] + # will update the first configured network try: conf_file = open(WPA_SUPPLICANT_CONF, 'r') diff --git a/static/js/main.js b/static/js/main.js index 9b8691e..c45a19a 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -482,7 +482,7 @@ function initUI() { $('input[type=text].number').each(function () { var $this = $(this); var $tr = $this.parent().parent(); - makeTextValidator($this, Number($tr.attr('min')), Number($tr.attr('max')), + makeNumberValidator($this, Number($tr.attr('min')), Number($tr.attr('max')), Boolean($tr.attr('floating')), Boolean($tr.attr('sign')), Boolean($tr.attr('required'))); }); diff --git a/templates/main.html b/templates/main.html index 75466b5..2962911 100644 --- a/templates/main.html +++ b/templates/main.html @@ -7,7 +7,7 @@ {% if config.get('strip') %}strip="true"{% endif %} {% if config.get('depends') %}depends="{{' '.join(config['depends'])}}"{% endif %} {% if config.get('min') is not none %}min="{{config['min']}}"{% endif %} - {% if config.get('max') is not none %}max="{{config['min']}}"{% endif %} + {% if config.get('max') is not none %}max="{{config['max']}}"{% endif %} {% if config.get('floating') %}floating="true"{% endif %} {% if config.get('sign') %}sign="true"{% endif %} {% if config.get('snap') is not none %}snap="{{config['snap']}}"{% endif %} -- 2.39.5