<filename>util/configuration.py
''' Configuration utility class '''
import configparser
import sys


class Configurer:
    '''
    Utility class to handle reading configuration parameters
    Throws if expected config file parameter is missing

    Config file format:
    [DEFAULT]
    key1=value1
    key2=value2
    '''

    def __init__(self, config_file='smartbee_actor.conf'):
        self.config = configparser.ConfigParser()
        self.config.read(config_file)

    def get_base_url(self):
        ''' Get base url string '''
        return self.config['SERVER']['url']

    def get_room_url(self):
        ''' Get room url string '''
        return self.get_base_url() + "/#/showRoom/" + self.config['TARGET']['room_id']

    def get_target_id(self):
        ''' Get HTML ID of target element of room '''
        return self.config['TARGET']['target_id']

    def get_password(self):
        ''' Get password string '''
        return self.config['SERVER']['password']

    def get_login_delay(self):
        ''' Get delay float to wait for login to complete '''
        return float(self.config['TIMING']['login_delay'])

    def get_logout_check_delay(self):
        ''' Get delay float for checking to see if a log out occurred '''
        return float(self.config['TIMING']['logout_check_delay'])

    def get_idle_refresh_delay(self):
        ''' Get delay float for how long to wait before forcing a refresh of the page '''
        try:
            return float(self.config['TIMING']['idle_refresh'])
        except:
            return 7200

    def get_system_restart_delay(self):
        ''' Get number of seconds until forcing a system restart; negative if no restart '''
        try:
            system_restart_delay = self.config['TIMING']['force_system_restart']
            if(system_restart_delay.isdigit()):
                return float(system_restart_delay)
            else:
                return -1
        except:
            return 24 * 3600

    def get_logging_level(self):
        ''' Get level of log messages '''
        try:
            return self.config['LOGGING']['level']
        except:
            return 'info'

<filename>util/configuration.py
''' Configuration utility class '''
import configparser
import sys


class Configurer:
    '''
    Utility class to handle reading configuration parameters
    Throws if expected config file parameter is missing

    Config file format:
    [DEFAULT]
    key1=value1
    key2=value2
    '''

    def __init__(self, config_file='smartbee_actor.conf'):
        self.config = configparser.ConfigParser()
        self.config.read(config_file)

    def get_base_url(self):
        ''' Get base url string '''
        return self.config['SERVER']['url']

    def get_room_url(self):
        ''' Get room url string '''
        return self.get_base_url() + "/#/showRoom/" + self.config['TARGET']['room_id']

    def get_target_id(self):
        ''' Get HTML ID of target element of room '''
        return self.config['TARGET']['target_id']

    def get_password(self):
        ''' Get password string '''
        return self.config['SERVER']['password']

    def get_login_delay(self):
        ''' Get delay float to wait for login to complete '''
        return float(self.config['TIMING']['login_delay'])

    def get_logout_check_delay(self):
        ''' Get delay float for checking to see if a log out occurred '''
        return float(self.config['TIMING']['logout_check_delay'])

    def get_idle_refresh_delay(self):
        ''' Get delay float for how long to wait before forcing a refresh of the page '''
        try:
            return float(self.config['TIMING']['idle_refresh'])
        except:
            return 7200

    def get_system_restart_delay(self):
        ''' Get number of seconds until forcing a system restart; negative if no restart '''
        try:
            system_restart_delay = self.config['TIMING']['force_system_restart']
            if(system_restart_delay.isdigit()):
                return float(system_restart_delay)
            else:
                return -1
        except:
            return 24 * 3600

    def get_logging_level(self):
        ''' Get level of log messages '''
        try:
            return self.config['LOGGING']['level']
        except:
            return 'info'

Configuration utility class Utility class to handle reading configuration parameters     Throws if expected config file parameter is missing      Config file format:     [DEFAULT]     key1=value1     key2=value2 Get base url string Get room url string #/showRoom/" + self.config['TARGET']['room_id'] Get HTML ID of target element of room Get password string Get delay float to wait for login to complete Get delay float for checking to see if a log out occurred Get delay float for how long to wait before forcing a refresh of the page Get number of seconds until forcing a system restart; negative if no restart Get level of log messages