Example #1
0
 def test_invalid_element_tree(self, *args, **keywargs):
     """ Test the parsing of an invalid XML using ElementTree. """
     from supvisors.sparser import Parser
     # create Parser instance
     with patch.object(self.supvisors.options, 'rules_file',
                       StringIO(InvalidXmlTest)):
         parser = Parser(self.supvisors)
     self.check_invalid(parser)
Example #2
0
 def test_valid_lxml(self):
     """ Test the parsing using lxml (optional dependency). """
     # perform the test
     from supvisors.sparser import Parser
     with patch.object(self.supvisors.options, 'rules_file',
                       StringIO(XmlTest)):
         parser = Parser(self.supvisors)
     self.check_valid(parser)
Example #3
0
 def test_invalid_lxml(self, mocked_print):
     """ Test the parsing of an invalid XML using lxml (optional dependency). """
     # perform the test
     from supvisors.sparser import Parser
     with patch.object(self.supvisors.options, 'rules_file',
                       StringIO(InvalidXmlTest)):
         with self.assertRaises(ValueError):
             Parser(self.supvisors)
Example #4
0
 def __init__(self, supervisord):
     """ Initialization of the attributes. """
     # store this instance in supervisord to ensure persistence
     supervisord.supvisors = self
     # get options from config file
     server_options = SupvisorsServerOptions()
     server_options.realize()
     self.options = server_options.supvisors_options
     # create logger
     stdout = supervisord.options.nodaemon
     self.logger = getLogger(self.options.logfile, self.options.loglevel,
                             Supvisors.LOGGER_FORMAT, True,
                             self.options.logfile_maxbytes,
                             self.options.logfile_backups, stdout)
     # configure supervisor info source
     self.info_source = SupervisordSource(supervisord)
     # set addresses and check local address
     self.address_mapper = AddressMapper(self.logger)
     self.address_mapper.addresses = self.options.address_list
     if not self.address_mapper.local_address:
         raise RPCError(
             Faults.SUPVISORS_CONF_ERROR,
             'local host unexpected in address list: {}'.format(
                 self.options.address_list))
     # create context data
     self.context = Context(self)
     # create application starter and stopper
     self.starter = Starter(self)
     self.stopper = Stopper(self)
     # create statistics handler
     self.statistician = StatisticsCompiler(self)
     # create the failure handler of crashing processes
     self.failure_handler = RunningFailureHandler(self)
     # create state machine
     self.fsm = FiniteStateMachine(self)
     # check parsing
     try:
         self.parser = Parser(self)
     except:
         self.logger.warn('cannot parse rules file: {}'.format(
             self.options.rules_file))
         self.parser = None
     # create event subscriber
     self.listener = SupervisorListener(self)
Example #5
0
 def test_no_parser(self, *args, **keywargs):
     """ Test the exception when no parser is available. """
     from supvisors.sparser import Parser
     # create Parser instance
     with self.assertRaises(ImportError):
         Parser(self.supvisors)