示例#1
0
 def _eventAuthRequest(self, event_dict, content):
     # render to logs, if enabled
     if self.verboseEvents:
         logger.info('Event received:\n%s' % utils.format_event(
             event_dict.content_type, event_dict, content=content))
     # construct a deferred object to use when we receive the
     ## command/reply event in response to the sendLine below
     self._deferred = defer.Deferred()
     self._deferred.command = 'auth'
     self._deferred.addCallback(self.authSuccess).addErrback(
         self.authFailure)
     # send the auth command
     self.sendLine('auth {password}'.format(password=self.password))
示例#2
0
 def _eventPlainText(self, event_dict, content):
     # parse the content into a dictionary of key:value pairs, along with
     ## any content block it may contain as the internal_content attribute
     ## on the content_dict object
     content_dict = utils.EventDict(content)
     # update the event dict with the key:value pairs from the content_dict
     event_dict.update(content_dict)
     # set some useful local variables
     event_name = event_dict.get('Event-Name', '').strip()
     event_subclass = event_dict.get('Event-Subclass', '').strip()
     # render to logs, if enabled
     if self.verboseEvents:
         title = event_dict.content_type
         if event_name:
             title = ' '.join([title, event_name])
         if event_subclass:
             title = ' '.join([title, event_subclass])
         logger.info('Event received:\n%s' % utils.format_event(
             title, event_dict, content=content_dict.content))
     # delegate the event to subscription functions
     self._eventPlainTextDelegator(event_dict, event_name,
         subclass=event_subclass, content=content_dict.content)
示例#3
0
 def _eventApiResponse(self, event_dict, content):
     # render to logs, if enabled
     if self.verboseEvents:
         title = event_dict.content_type
         if hasattr(self._deferred, 'command'):
             command = self._deferred.command
             if hasattr(self._deferred, 'args'):
                 command = ' '.join((command,) + self._deferred.args)
             title = ' '.join([title, repr(command)])
         logger.info('Event received:\n%s' % utils.format_event(
             title, event_dict, content=content))
     # determine how to handle the result
     if content.startswith('-ERR'):
         if self._deferred:
             self._deferred.errback(content)
             self._deferred = None
             return
         raise EventError(content)
     if self._deferred:
         self._deferred.callback(content)
         self._deferred = None
         return
     logger.info(content)
示例#4
0
 def render(self):
     """
     Returns a string representation of the event, primarily for 
     debugging purposes.
     """
     return utils.format_event(str(self), self.dict, content=self.content)