def __init__(self): """ Constructor. """ self._config = ConfigParser.ConfigParser() self.logger = SEKLogger(__name__, 'INFO') self.fileUtil = SEKFileUtil() self.dbUtil = SEKDBUtil() self.cursor = None configFilePath = '~/.smart-inverter.cfg' if self.fileUtil.isMoreThanOwnerReadableAndWritable( os.path.expanduser(configFilePath)): self.logger.log( "Configuration file permissions are too permissive. Operation " "will not continue.", 'error') sys.exit(-1) try: self._config.read(['site.cfg', os.path.expanduser(configFilePath)]) except: self.logger.log( "Critical error: The data in {} cannot be " "accessed successfully.".format(configFilePath), 'ERROR') sys.exit(-1)
def __init__(self): """ Constructor. """ self._config = ConfigParser.ConfigParser() self.logger = SEKLogger(__name__, 'INFO') self.fileUtil = SEKFileUtil() # Define tables that will have data inserted. Data will only be inserted # to tables that are defined here. self.insertTables = ('MeterData', 'RegisterData', 'RegisterRead', 'Tier', 'Register', 'IntervalReadData', 'Interval', 'Reading', 'EventData', 'Event') # Check permissions on the config file. Refuse to run if the permissions # are not set appropriately. configFilePath = '~/.msg-data-operations.cfg' if self.fileUtil.isMoreThanOwnerReadableAndWritable( os.path.expanduser(configFilePath)): self.logger.log( "Configuration file permissions are too permissive. Operation " "will not continue.", 'error') sys.exit() try: self._config.read(['site.cfg', os.path.expanduser(configFilePath)]) except: self.logger.log( "Critical error: The data in {} cannot be " "accessed successfully.".format(configFilePath), 'ERROR') sys.exit(-1)