#!/router/bin/python

import os
import outer_packages
import zmq
import threading
import logging
import CCustomLogger
from json import JSONDecoder
from common.trex_status_e import TRexStatus

# setup the logger
CCustomLogger.setup_custom_logger('TRexServer')
logger = logging.getLogger('TRexServer')

class ZmqMonitorSession(threading.Thread):
    def __init__(self, trexObj , zmq_port):
        super(ZmqMonitorSession, self).__init__()
        self.stoprequest    = threading.Event()
#       self.terminateFlag  = False
        self.first_dump     = True
        self.zmq_port       = zmq_port
        self.zmq_publisher  = "tcp://localhost:{port}".format( port = self.zmq_port )
#       self.context        = zmq.Context()
#       self.socket         = self.context.socket(zmq.SUB)
        self.trexObj        = trexObj
        self.expect_trex    = self.trexObj.expect_trex     # used to signal if T-Rex is expected to run and if data should be considered
        self.decoder        = JSONDecoder()
        logger.info("ZMQ monitor initialization finished")

    def run (self):
Beispiel #2
0
#!/router/bin/python

import os
import outer_packages
import zmq
import threading
import logging
import CCustomLogger
from json import JSONDecoder
from common.trex_status_e import TRexStatus

# setup the logger
CCustomLogger.setup_custom_logger("TRexServer")
logger = logging.getLogger("TRexServer")


class ZmqMonitorSession(threading.Thread):
    def __init__(self, trexObj, zmq_port):
        super(ZmqMonitorSession, self).__init__()
        self.stoprequest = threading.Event()
        self.first_dump = True
        self.zmq_port = zmq_port
        self.zmq_publisher = "tcp://localhost:{port}".format(port=self.zmq_port)
        self.trexObj = trexObj
        self.expect_trex = (
            self.trexObj.expect_trex
        )  # used to signal if T-Rex is expected to run and if data should be considered
        self.decoder = JSONDecoder()
        logger.info("ZMQ monitor initialization finished")

    def run(self):