Пример #1
0
    def poll_QoS(self):
        """
        Gets the latest camera/object metrics from the QoS server. This
        function returns a list of VidFeed objects, or None if the input data
        was invalid.
        """
        response = self.QoS_server.recv(self.BUFFER_SIZE)
        if not response: # assume dropped connection
            raise socket.error('No data received from QoS server')

        try:
            lines = response.decode('utf-8').splitlines()
            pr = qosupdate.parse(lines)
        except Exception as ex:
            log('Invalid data received from server: ' + str(ex))
            return None
        return pr
Пример #2
0
"""
This module handles the details of communicating with the QoS server.
"""
from __future__ import print_function, with_statement
from datetime import datetime
from vidcontrol import VidFeed, VidControl
from qosupdate import parse, prepare

# Test for sample response
# NOTE: The server-sim.py program must be running for this test to execute
# successfully. This is a side effect of using the VidControl class.
if __name__ == '__main__':
    with open('./sample-qos-response.txt', 'r') as f:
        text = f.read()

    messages = text.split('>>>\n')
    for m in messages[1:]:
        lines = m.splitlines()
        feed_data = parse(lines)

        print('\n>>>\n')
        print('Timestamp: ' + str(feed_data[0]))

        print('Add/update feeds:')
        for x in feed_data[1]:
            print('\t' + str(x))

        print('Delete feeds:')
        for x in feed_data[2]:
            print('\t' + str(x))