예제 #1
0
 def __init__(self, *args, **kwargs):
     """
     Creates an instance of the IRCNotifyWorker.
     """
     Worker.__init__(self, *args, **kwargs)
     self.__initial_start = True  # Records if we are in the initial start
     self._irc_comm = Queue()
     self._irc_resp = Queue()
     self._irc_client = Process(target=IRCLoop, args=(self._irc_comm, self._irc_resp, self.app_logger, self._config))
     self._irc_client.start()
예제 #2
0
 def run_forever(self):
     """
     Override run_forever so we can wrap IRC connection/disconnection.
     """
     # Wait to get the connection response before joining the bus
     try:
         if self.__initial_start:
             self.__initial_start = False
             if self._irc_resp.get(timeout=30) is not True:
                 raise Empty
         # Execute Worker's run_forver
         Worker.run_forever(self)
         self._irc_client.terminate()
         self._irc_client.join()
         self.app_logger.info("Disconnected from IRC.")
     except Empty:
         self.app_logger.fatal("Unable to connect to IRC!")
예제 #3
0
 def __init__(self, *args, **kwargs):
     Worker.__init__(self, *args, **kwargs)
     # There are no redactions by default
     self._redaction_rx = None
     # Attempt to pull redactions from the worker config
     redaction_cfg = self._config.get('redactions', [])
     if redaction_cfg:
         # if redactions exist in the config then build a regex from
         # the config to use for substitution.
         redaction_rx_build = '('
         for redaction in redaction_cfg:
             redaction_str = '.*%s[^\\n]*\\n|' % redaction
             self.app_logger.debug('Adding "%s"' % redaction)
             redaction_rx_build += redaction_str
         # Remove the last | and end the regex
         redaction_rx_build = redaction_rx_build[0:-1] + ')'
         self._redaction_rx = re.compile(redaction_rx_build)
         self.app_logger.info('Redactions are turned on.')
         self.app_logger.debug('Redaction RX: %s' % redaction_rx_build)