From: Calin Crisan Date: Sun, 29 Sep 2013 08:26:14 +0000 (+0300) Subject: conf and run path are now configurable X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=574643e012b3ee775e66e8735d1feef2b0725a19;p=motioneye-debian conf and run path are now configurable --- diff --git a/doc/todo.txt b/doc/todo.txt index 625387c..2ff1d97 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -1,5 +1,4 @@ -> 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 1278a2a..6eeb272 100644 --- a/settings.py +++ b/settings.py @@ -5,7 +5,7 @@ import sys PROJECT_PATH = os.path.dirname(sys.argv[0]) -CONF_PATH = os.path.join(PROJECT_PATH, 'conf') # TODO use this +CONF_PATH = os.path.join(PROJECT_PATH, 'conf') RUN_PATH = PROJECT_PATH DEBUG = True diff --git a/src/config.py b/src/config.py index c5c1923..86273d0 100644 --- a/src/config.py +++ b/src/config.py @@ -9,11 +9,10 @@ from collections import OrderedDict import settings -_CONFIG_DIR = 'conf' _CAMERA_CONFIG_FILE_NAME = 'thread-%(id)s.conf' -_MAIN_CONFIG_FILE_PATH = os.path.join(_CONFIG_DIR, 'motion.conf') -_CAMERA_CONFIG_FILE_PATH = os.path.join(_CONFIG_DIR, _CAMERA_CONFIG_FILE_NAME) +_MAIN_CONFIG_FILE_PATH = os.path.join(settings.CONF_PATH, 'motion.conf') +_CAMERA_CONFIG_FILE_PATH = os.path.join(settings.CONF_PATH, _CAMERA_CONFIG_FILE_NAME) def get_main(as_lines=False): @@ -107,7 +106,7 @@ def set_main(data): def get_camera_ids(): - config_path = os.path.join(settings.PROJECT_PATH, _CONFIG_DIR) + config_path = settings.CONF_PATH logging.debug('listing config dir %(path)s...' % {'path': config_path}) diff --git a/src/motionctl.py b/src/motionctl.py index 69d3082..0ee23ec 100644 --- a/src/motionctl.py +++ b/src/motionctl.py @@ -18,7 +18,7 @@ def start(): 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_config_path = os.path.join(settings.CONF_PATH, 'motion.conf') motion_log_path = os.path.join(settings.RUN_PATH, 'motion.log') motion_pid_path = os.path.join(settings.RUN_PATH, 'motion.pid') diff --git a/static/js/base-site.js b/static/js/base-site.js index 61a9787..bd3ab37 100644 --- a/static/js/base-site.js +++ b/static/js/base-site.js @@ -2,7 +2,7 @@ var pushConfigs = {}; - /* Ajax */ + /* utils */ function ajax(method, url, data, callback) { var options = { @@ -27,6 +27,44 @@ function ajax(method, url, data, callback) { $.ajax(options); } +Object.keys = Object.keys || (function () { + var hasOwnProperty = Object.prototype.hasOwnProperty; + var hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'); + var dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ]; + var dontEnumsLength = dontEnums.length; + + return function (obj) { + if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) { + return []; + } + + var result = []; + for (var prop in obj) { + if (hasOwnProperty.call(obj, prop)) { + result.push(prop); + } + } + + if (hasDontEnumBug) { + for (var i = 0; i < dontEnumsLength; i++) { + if (hasOwnProperty.call(obj, dontEnums[i])) { + result.push(dontEnums[i]); + } + } + } + + return result; + }; +})(); + /* UI */ @@ -478,7 +516,7 @@ function showApply() { applyButton.html('Apply'); applyButton.css('display', 'inline-block'); applyButton.animate({'opacity': '1'}, 100); - applyButton.removeClass('inactive'); + applyButton.removeClass('progress'); } function showProgress() { @@ -529,7 +567,12 @@ function doApply() { function testReady() { if (finishedCount >= configs.length) { - hideApply(); + if (Object.keys(pushConfigs).length === 0) { + hideApply(); + } + else { + showApply(); + } } }