# 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):


import os
import re
import signal
import subprocess
import sys
import time
import ravel.util
from ravel.log import logger
    def is_running(cls):
        """Check if this or another Pox instance is running
           returns: true if pox is running, false otherwise"""
        output = os.popen("ps awx").read()
        if "pox.py" in output:
            return True
        else:
            return False

    def start(self, cargs=None):
        """Start the Pox process
           cargs: arguments to pass to the controller"""
        pox = os.path.join(ravel.util.Config.PoxDir, "pox.py")
        if not os.path.exists(pox):
            logger.error("cannot find pox.py at: {0}. "
                         "Is PoxDir set correctly in ravel.cfg?"
                         .format(pox))
            sys.exit(0)

        if cargs is None:
            cargs = ["log.level",
                     "--DEBUG",
                     "openflow.of_01",
                     "--port={0}".format(ravel.util.Config.PoxPort),
                     self.app,
                     "openflow.discovery"]

        ravel.util.append_path(ravel.util.resource_file())
        env = os.environ.copy()
        env["PYTHONPATH"] = ":".join(sys.path)

# 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
import os
import re
import signal
import subprocess
import sys
import time
import ravel.util
from ravel.log import logger

    def is_running(cls):
        """Check if this or another Pox instance is running
           returns: true if pox is running, false otherwise"""
        output = os.popen("ps awx").read()
        if "pox.py" in output:
            return True
        else:
            return False

    def start(self, cargs=None):
        """Start the Pox process
           cargs: arguments to pass to the controller"""
        pox = os.path.join(ravel.util.Config.PoxDir, "pox.py")
        if not os.path.exists(pox):
            logger.error("cannot find pox.py at: {0}. "
                         "Is PoxDir set correctly in ravel.cfg?"
                         .format(pox))
            sys.exit(0)

        if cargs is None:
            cargs = ["log.level",
                     "--DEBUG",
                     "openflow.of_01",
                     "--port={0}".format(ravel.util.Config.PoxPort),
                     self.app,
                     "openflow.discovery"]

        ravel.util.append_path(ravel.util.resource_file())
        env = os.environ.copy()
        env["PYTHONPATH"] = ":".join(sys.path)

        logger.debug("pox with params: %s", " ".join(cargs))