Esempio n. 1
0
    def _client_connect(self):
        """Create a new DLTClient

        :param int timeout: Time in seconds to wait for connection.
        :returns: True if connected, False otherwise
        :rtype: bool
        """
        logger.debug("Creating DLTClient (ip_address='%s', logfile='%s')", self._ip_address, self._filename)
        self._client = DLTClient(servIP=self._ip_address, verbose=self.verbose)
        connected = self._client.connect(self.timeout)
        if connected:
            logger.info("DLTClient connected to %s", self._client.servIP)
        return connected
Esempio n. 2
0
def create_messages(stream, from_file=False):
    if from_file is False:
        stream.seek(0)
        buf = stream.read()

        client = DLTClient()
        client.receiver.buf = ctypes.create_string_buffer(buf)
        client.receiver.bytesRcvd = len(buf)

        return client.read_message()

    _, tmpname = tempfile.mkstemp(suffix=b"")
    tmpfile = open(tmpname, "wb")
    tmpfile.write(stream)
    tmpfile.flush()
    tmpfile.seek(0)
    tmpfile.close()

    atexit.register(os.remove, tmpname)

    msgs = load(tmpname)
    return msgs
 def setUp(self):
     self.client = DLTClient()
     self.client._connected_socket = socket.socket()
Esempio n. 4
0
 def setUp(self):
     # - patch port so that connect fails even if dlt-daemon is running
     self.client = DLTClient(servIP='127.0.0.1', port=424242)