def logError(self, failure): """Log an error and re-schedule the configuration file monitor.""" failure.trap(Exception) log.err(failure) self.fileStat = None if not self.reloadTask.running: self.startObserving()
def parseLegacyConfig(self, rawConfig): """Parse a legacy (eval) configuration file.""" config = {} for line in rawConfig.split('\n'): try: line = line.strip() if not line or line.startswith('#'): continue server = ast.literal_eval(line) host = server.pop('host') except (KeyError, SyntaxError, TypeError, ValueError) as ex: # We catch exceptions here (rather than simply allow them to # bubble up to FileConfigurationObserver.logError) because we # want to try and parse as much of the file as we can. log.err(ex, 'Bad configuration line: %s' % line) continue else: config[host] = {} try: config[host]['enabled'] = server['enabled'] except: pass try: config[host]['fwmethod'] = server['fwmethod'] except: pass try: config[host]['weight'] = server['weight'] except: pass return config
def parseLegacyConfig(self, rawConfig): """Parse a legacy (eval) configuration file.""" config = {} for line in rawConfig.split('\n'): try: line = line.strip() if not line or line.startswith('#'): continue server = ast.literal_eval(line) host = server.pop('host') except (KeyError, SyntaxError, TypeError, ValueError) as ex: # We catch exceptions here (rather than simply allow them to # bubble up to FileConfigurationObserver.logError) because we # want to try and parse as much of the file as we can. log.err(ex, 'Bad configuration line: %s' % line) continue else: config[host] = {} try: config[host]['enabled'] = server['enabled'] except: pass try: config[host]['fwmethod']= server['fwmethod'] except: pass try: config[host]['weight'] = server['weight'] except: pass return config