From: Calin Crisan Date: Mon, 23 Feb 2015 15:34:50 +0000 (+0200) Subject: added support for separators in additional config X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=85722141611ab55dce513e43e56e00fbd4fe1e12;p=motioneye-debian added support for separators in additional config --- diff --git a/motioneye.py b/motioneye.py index 915ba8b..9648fd3 100755 --- a/motioneye.py +++ b/motioneye.py @@ -148,9 +148,9 @@ def _test_requirements(): print('SMB_SHARES require root privileges') return False - if settings.ENABLE_REBOOT: - print('reboot requires root privileges') - return False +# if settings.ENABLE_REBOOT: # TODO +# print('reboot requires root privileges') +# return False try: import tornado # @UnusedImport diff --git a/src/config.py b/src/config.py index f178857..caf6849 100644 --- a/src/config.py +++ b/src/config.py @@ -1416,8 +1416,8 @@ def _set_default_motion_camera(camera_id, data, old_motion=False): data.setdefault('on_event_end', '') -def get_additional_structure(camera): - if _additional_structure_cache.get(camera) is None: +def get_additional_structure(camera, separators=False): + if _additional_structure_cache.get((camera, separators)) is None: logging.debug('loading additional config structure for %s' % ('camera' if camera else 'main')) # gather sections @@ -1432,7 +1432,7 @@ def get_additional_structure(camera): if bool(result.get('camera')) != bool(camera): continue - + result['name'] = func.func_name sections[func.func_name] = result @@ -1447,16 +1447,19 @@ def get_additional_structure(camera): if bool(result.get('camera')) != bool(camera): continue - + + if result['type'] == 'separator' and not separators: + continue + result['name'] = func.func_name configs[func.func_name] = result section = sections.setdefault(result.get('section'), {}) section.setdefault('configs', []).append(result) - _additional_structure_cache[camera] = sections, configs + _additional_structure_cache[(camera, separators)] = sections, configs - return _additional_structure_cache[camera] + return _additional_structure_cache[(camera, separators)] def _get_additional_config(data, camera): diff --git a/src/handlers.py b/src/handlers.py index f39fcf0..9d617b4 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -142,8 +142,8 @@ class MainHandler(BaseHandler): import motioneye # additional config - main_sections = config.get_additional_structure(camera=False)[0] - camera_sections = config.get_additional_structure(camera=True)[0] + main_sections = config.get_additional_structure(camera=False, separators=True)[0] + camera_sections = config.get_additional_structure(camera=True, separators=True)[0] self.render('main.html', frame=False, diff --git a/templates/main.html b/templates/main.html index 314347d..9e1aa01 100644 --- a/templates/main.html +++ b/templates/main.html @@ -15,6 +15,9 @@ {% if config.get('ticksnum') is not none %}ticksnum="{{config['ticksnum']}}"{% endif %} {% if config.get('decimals') is not none %}decimals="{{config['decimals']}}"{% endif %} {% if config.get('unit') %}unit="{{config['unit']}}"{% endif %}> + {% if config['type'] == 'separator' %} +
+ {% else %} {{config['label']}} {% if config['type'] == 'str' %} @@ -36,6 +39,7 @@ {% endif %} {% if config.get('description') %}?{% endif %} + {% endif %} {%- endmacro %}