def receive_message(self):
     try:
         incoming_message = self.read_until('\n', self.timeout).strip()
         if incoming_message.strip():
             self.logger.debug("Incoming string \"%s\"" % incoming_message)
             message = MessageFactory.get_message(incoming_message)
             if message:
                 if message.is_response():
                     message.set_origination(
                                 self.commands_unresponded.popleft()
                             )
                 elif message.is_reset_message():
                     # Command didn't ask for a response
                     if self.commands_unresponded:
                         self.commands_unresponded.popleft()
                 self.logger.info("Received message %s" % message.__repr__())
                 return message
     except ValueError as e:
         pass
     except IndexError as e:
         self.logger.warning(
                 "Unable to create message for \"%s\"; %s" % (
                     incoming_message, 
                     e
                 )
             )
     except Exception as e:
         return e
Exemplo n.º 2
0
def _receive_message(client):
    while True:
        incoming_message = client.read_until('\n', 10).strip()
        if incoming_message is not None and incoming_message.strip():
            logger.info("Received: %s", incoming_message)
            message = MessageFactory.get_message(incoming_message)
            if message:
                return message
Exemplo n.º 3
0
def _receive_message(client):
    while True:
        incoming_message = client.read_until('\n', 10).strip()
        if incoming_message is not None and incoming_message.strip():
            logger.info("Received: %s", incoming_message)
            message = MessageFactory.get_message(incoming_message)
            if message:
                return message
Exemplo n.º 4
0
 def receive_message(self):
     try:
         incoming_message = self.read_until('\n', self.timeout).strip()
         if incoming_message.strip():
             self.logger.debug("Incoming string \"%s\"" % incoming_message)
             message = MessageFactory.get_message(incoming_message)
             if message:
                 if message.is_response():
                     message.set_origination(
                         self.commands_unresponded.popleft())
                 elif message.is_reset_message():
                     # Command didn't ask for a response
                     if self.commands_unresponded:
                         self.commands_unresponded.popleft()
                 self.logger.info("Received message %s" %
                                  message.__repr__())
                 return message
     except ValueError as e:
         pass
     except IndexError as e:
         self.logger.warning("Unable to create message for \"%s\"; %s" %
                             (incoming_message, e))
     except Exception as e:
         return e