worktree-test/configfile.py

41 lines
1.8 KiB
Python
Raw Permalink Normal View History

2021-03-03 15:39:43 +00:00
from configparser import ConfigParser
# instantiate
class Configuration():
def __init__(self):
self.config = ConfigParser()
# parse existing file
self.config.read('/var/lib/cloud9/WMA/config.ini')
# read General settings
self.debug_mode = self.config.getboolean('GENERAL','debug_mode')
self.path = self.config.get('GENERAL','path')
#read DB settings
self.db_file_name = self.config.get('DB_SETTINGS','db_file_name')
self.table_name = self.config.get('DB_SETTINGS','tablename')
self.days_archive = self.config.getint('DB_SETTINGS','days_archive')
# read MQTT settings
self.qos = self.config.getint('MQTT_SETTINGS','qos')
self.topic_debug = self.config.get('MQTT_SETTINGS','topic_debug')
self.numberOfHosts = self.config.getint('MQTT_SETTINGS','NumberOfHosts')
self.numberOfPublishers = self.config.getint('MQTT_SETTINGS','NumberOfPublishers')
# read rs 485 settings
self.baudrate = self.config.getint('RS485_SETTINGS','baudrate') # Baud
self.parity = self.config.get('RS485_SETTINGS','parity')
self.stopbits = bytesize = self.config.getint('RS485_SETTINGS','stopbits')
self.mode = self.config.get('RS485_SETTINGS','mode')
self.close_port_after_each_call= self.config.getboolean('RS485_SETTINGS','close_port_after_each_call')
self.debug_serial=self.config.getboolean('RS485_SETTINGS','debug_serial')
self.timeout =self.config.getfloat('RS485_SETTINGS','timeout')
self.handle_local_echo = self.config.getboolean('RS485_SETTINGS','handle_local_echo')
self.uart=self.config.get('RS485_SETTINGS','uart')
self.port_name=self.config.get('RS485_SETTINGS','port_name')
self.slave_address=self.config.getint('RS485_SETTINGS','slave_address')