Coverage for janitoo.value_factory.config : 56%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
"""
This file is part of Janitoo.
Janitoo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Janitoo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Janitoo. If not, see <http://www.gnu.org/licenses/>.
"""
# Set default logging handler to avoid "No handler found" warnings.
############################################################## #Check that we are in sync with the official command classes #Must be implemented for non-regression
##############################################################
return JNTValueConfigInteger(**kwargs)
return JNTValueConfigFloat(**kwargs)
return JNTValueConfigBoolean(**kwargs)
return JNTValueConfigArray(**kwargs)
return JNTValueConfigList(**kwargs)
""" """ """ """ get_data_cb=get_data_cb, set_data_cb=set_data_cb, cmd_class=COMMAND_CONFIGURATION, genre=genre, is_readonly=is_readonly, is_writeonly=is_writeonly, **kwargs)
""" """ if index not in self.instances: self.instances[index] = {} try: if index not in self.instances or self.instances[index] != data: self.instances[index]['data'] = data self.options.set_option(node_uuid, '%s_%s'%(self.uuid, index), '%s'%data) except: logger.exception('Exception when writing %s_%s for node %s'%(self.uuid, index, node_uuid))
""" """ except:
""" """ index=index, type=0x08, **kwargs)
""" """ list_items = kwargs.pop('list_items', ['value1', 'value2']) index=index, type=0x05, list_items=list_items, **kwargs)
""" """ index=index, type=0x14, **kwargs)
""" """ help = kwargs.pop('help', 'A boolean') label = kwargs.pop('label', 'Bool') index = kwargs.pop('index', 0) get_data_cb = kwargs.pop('get_data_cb', self._get_data_bool) JNTValueConfigGeneric.__init__(self, entry_name=entry_name, help=help, label=label, get_data_cb=get_data_cb, index=index, type=0x01, **kwargs)
""" """ try: data = self._get_data(node_uuid, index) if data is not None: self.instances[index]['data'] = bool(data) else: self.instances[index]['data'] = None except: logger.exception('Exception when retrieving %s_%s for node %s'%(self.uuid, index, node_uuid))
""" """ help = kwargs.pop('help', 'A float') label = kwargs.pop('label', 'Float') index = kwargs.pop('index', 0) get_data_cb = kwargs.pop('get_data_cb', self._get_data_integer) JNTValueConfigGeneric.__init__(self, entry_name=entry_name, help=help, label=label, get_data_cb=get_data_cb, index=index, type=0x04, **kwargs)
""" """ try: data = self._get_data(node_uuid, index) if data is not None: self.instances[index]['data'] = int(data) else: self.instances[index]['data'] = None except: logger.exception('Exception when retrieving %s_%s for node %s'%(self.uuid, index, node_uuid))
""" """ help = kwargs.pop('help', 'An integer') label = kwargs.pop('label', 'integer') index = kwargs.pop('index', 0) get_data_cb = kwargs.pop('get_data_cb', self._get_data_float) JNTValueConfigGeneric.__init__(self, entry_name=entry_name, help=help, label=label, get_data_cb=get_data_cb, index=index, type=0x04, **kwargs)
""" """ try: data = self._get_data(node_uuid, index) if data is not None: self.instances[index]['data'] = float(data) else: self.instances[index]['data'] = None except: logger.exception('Exception when retrieving %s_%s for node %s'%(self.uuid, index, node_uuid))
""" """ help = kwargs.pop('help', 'An array of strings separated by |') label = kwargs.pop('label', 'Array') index = kwargs.pop('index', 0) get_data_cb = kwargs.pop('get_data_cb', self._get_data_float) JNTValueConfigGeneric.__init__(self, entry_name=entry_name, help=help, label=label, get_data_cb=get_data_cb, index=index, type=0x16, **kwargs)
""" """ try: data = self._get_data(node_uuid, index) if data is not None: self.instances[index]['data'] = data.split('|') else: self.instances[index]['data'] = None except: logger.exception('Exception when retrieving %s_%s for node %s'%(self.uuid, index, node_uuid)) return self.instances[index]['data'] |