예제 #1
0
 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()
예제 #2
0
파일: config.py 프로젝트: runt18/PyBal
 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()
예제 #3
0
 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
예제 #4
0
 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