Coverage for janitoo.options : 54%

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 -*-
A thread that handle a bus, ... ie i2e, onewire,
It also handle the controller for the janitoo protocol
How do what :
The tread : - hold the mqttc - ask the nodeman to boot : - get an HADD for the controller - get configuration for the controller and start the i2c bus, the onewire bus, ..... - get an HADD for each nodes - get configuration of the node and start it : ie the lcd03 of i2c, the cpu of the rapsy, ...
Reloading configration: - inside the run loop of the thread so need to kill it and re-create a new one : only possible in the server. The server (=the rapsy server) can do it but it should be accessible on mqtt. """
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.
#We must NOT subsitute % in value for alembic (database section)
"""The options
:param options: The options used to start the worker. :type clientid: str """ #retrieve parameters in file
"""Load system section from file
:param options: The options used to start the worker. :type clientid: str """ #retrieve parameters in file system = self.get_options('system')
"""Retrieve options from a section """ #~ print self.data['conf_file'] #~ print "section ", section, " in cache", section in self._cache #~ print "data ", self.data #~ print "items ", config.items(section) #~ print self._cache[section] #~ except ConfigParser.NoSectionError: except: logger.exception("get_options") pass
"""Retrieve options from a section """ #print self.data['conf_file'] if default is None: self._cache[section][key] = opt return self._cache[section][key] else: if type(default) == type(0): try: self._cache[section][key] = int(opt) return self._cache[section][key] except: logger.exception("[%s] - Exception when converting option to integer : [%s] %s = %s", self.__class__.__name__, section, key, opt) return None elif type(default) == type(0.0): try: self._cache[section][key] = float(opt) return self._cache[section][key] except: logger.exception("[%s] - Exception when converting option to float : [%s] %s = %s", self.__class__.__name__, section, key, opt) return None #~ except ValueError:
"""Retrieve options from a section """ if section not in self._cache: self.get_options(section) #print self.data['conf_file'] if 'conf_file' in self.data and self.data['conf_file'] is not None: config = RawConfigParser() config.read([self.data['conf_file']]) if config.has_section(section) == False: config.add_section(section) self._cache[section][key] = value config.set(section, key, "%s"%value) with open(self.data['conf_file'], 'wb') as configfile: config.write(configfile) return True
"""Retrieve options from a section """ if section not in self._cache: self.get_options(section) #print self.data['conf_file'] if 'conf_file' in self.data and self.data['conf_file'] is not None: config = RawConfigParser() config.read([self.data['conf_file']]) if config.has_section(section) == False: config.add_section(section) if section not in self._cache: self._cache[section] = {} for key in data: self._cache[section][key] = data[key] config.set(section, key, "%s"%data[key]) with open(self.data['conf_file'], 'wb') as configfile: config.write(configfile) return True
"""Retrieve options from a section """ #print self.data['conf_file'] if 'conf_file' in self.data and self.data['conf_file'] is not None: config = RawConfigParser() config.read([self.data['conf_file']]) for key in data: config.remove_option(section, key) if section in self._cache and key in self._cache[section]: del self._cache[section][key] with open(self.data['conf_file'], 'wb') as configfile: config.write(configfile) return True
"""Remove a n entire section """ #print self.data['conf_file'] if 'conf_file' in self.data and self.data['conf_file'] is not None: config = RawConfigParser() config.read([self.data['conf_file']]) config.remove_section(section) with open(self.data['conf_file'], 'wb') as configfile: config.write(configfile) return True if section in self._cache: del self._cache[section]
"""Retrieve options which started with a key from a section """ #print self.data['conf_file']
"""Retrieve settings from a section """
"""Retrieve component's configuration from a section """ return self.get_options_key("%s.%s"%(section,component), "settings.")
"""Retrieve auto_start option from a section """ #print self.data['conf_file']
"""Convert a string to bool """ if data == "0" or data == "FALSE" or data == 'OFF' or data == 'NO': return False return True |