# Path: ravel/log.py
# LEVELS = { "debug" : logging.DEBUG,
#            "info" : logging.INFO,
#            "warning" : logging.WARNING,
#            "error" : logging.ERROR,
#            "critical" : logging.CRITICAL
#        }
# DEFAULT_LEVEL = logging.ERROR
# MSG_FORMAT = "%(levelname)s:%(funcName)s: %(message)s"
# class Singleton(type):
# class RavelLogger(Logger, object):
#     def __init__(cls, name, bases, dict_):
#     def __call__(cls, *args, **kw):
#     def __init__(self):
#     def setLogLevel(self, levelname=None):
# 
# Path: ravel/of.py
# OFPP_FLOOD = 65531
# 
# OFPFC_ADD = 0
# 
# OFPFC_DELETE = 3
# 
# OFPFC_DELETE_STRICT = 4


import os
import pickle
import threading
import time
import xmlrpclib
import sysv_ipc
import ravel.profiling
from SimpleXMLRPCServer import SimpleXMLRPCServer
from ravel.log import logger
from ravel.of import OFPP_FLOOD, OFPFC_ADD, OFPFC_DELETE, OFPFC_DELETE_STRICT

    def stop(self, event=None):
        """Stop the receiver thread
           event: an optional quit message"""
        pass

class MsgQueueSender(MessageSender):
    "A message queue-based message sender"

    def __init__(self, queue_id):
        "queue_id: the integer id of the queue to be used"
        self.queue_id = queue_id
        pc = ravel.profiling.PerfCounter("mq_connect")
        pc.start()
        try:
            self.mq = sysv_ipc.MessageQueue(self.queue_id,
                                            mode=0777)
        except sysv_ipc.ExistentialError, e:
            logger.warning("queue {0} does not exist: {1}"
                           .format(self.queue_id, e))
            self.mq = sysv_ipc.MessageQueue(self.queue_id,
                                            sysv_ipc.IPC_CREAT,
                                            mode=0777)
        pc.stop()

    def send(self, msg):
        """Send the specified message
           msg: the message to send"""
        pc = ravel.profiling.PerfCounter("mq_send")
        pc.start()

# Path: ravel/log.py
# LEVELS = { "debug" : logging.DEBUG,
#            "info" : logging.INFO,
#            "warning" : logging.WARNING,
#            "error" : logging.ERROR,
#            "critical" : logging.CRITICAL
#        }
# DEFAULT_LEVEL = logging.ERROR
# MSG_FORMAT = "%(levelname)s:%(funcName)s: %(message)s"
# class Singleton(type):
# class RavelLogger(Logger, object):
#     def __init__(cls, name, bases, dict_):
#     def __call__(cls, *args, **kw):
#     def __init__(self):
#     def setLogLevel(self, levelname=None):
# 
# Path: ravel/of.py
# OFPP_FLOOD = 65531
# 
# OFPFC_ADD = 0
# 
# OFPFC_DELETE = 3
# 
# OFPFC_DELETE_STRICT = 4


# Path: ravel/messaging.py
import os
import pickle
import threading
import time
import xmlrpclib
import sysv_ipc
import ravel.profiling
from SimpleXMLRPCServer import SimpleXMLRPCServer
from ravel.log import logger
from ravel.of import OFPP_FLOOD, OFPFC_ADD, OFPFC_DELETE, OFPFC_DELETE_STRICT


    def stop(self, event=None):
        """Stop the receiver thread
           event: an optional quit message"""
        pass

class MsgQueueSender(MessageSender):
    "A message queue-based message sender"

    def __init__(self, queue_id):
        "queue_id: the integer id of the queue to be used"
        self.queue_id = queue_id
        pc = ravel.profiling.PerfCounter("mq_connect")
        pc.start()
        try:
            self.mq = sysv_ipc.MessageQueue(self.queue_id,
                                            mode=0777)
        except sysv_ipc.ExistentialError, e:
            logger.warning("queue {0} does not exist: {1}"
                           .format(self.queue_id, e))
            self.mq = sysv_ipc.MessageQueue(self.queue_id,
                                            sysv_ipc.IPC_CREAT,
                                            mode=0777)
        pc.stop()

    def send(self, msg):
        """Send the specified message
           msg: the message to send"""
        pc = ravel.profiling.PerfCounter("mq_send")
        pc.start()

        logger.debug("mq: sending message %s", msg)