# Path: mom/unixrpc.py
# class UnixXmlRpcServer(socketserver.UnixStreamServer,
#                        xmlrpc_server.SimpleXMLRPCDispatcher):
#     address_family = socket.AF_UNIX
#     allow_address_reuse = True
# 
#     def __init__(self, sock_path, request_handler=UnixXmlRpcHandler,
#                  logRequests=0):
#         if os.path.exists(sock_path):
#             os.unlink(sock_path)
#         self.logRequests = logRequests
#         xmlrpc_server.SimpleXMLRPCDispatcher.__init__(self,
#                                                            encoding=None,
#                                                            allow_none=1)
#         socketserver.UnixStreamServer.__init__(self, sock_path,
#                                                request_handler)


import threading
import six
from six.moves.xmlrpc_client import Marshaller
from six.moves.xmlrpc_server import SimpleXMLRPCServer
from six.moves.xmlrpc_server import SimpleXMLRPCRequestHandler
from .unixrpc import UnixXmlRpcServer
from .LogUtils import *
    The RPCServer thread provides an API for external programs to interact
    with MOM.
    """
    def __init__(self, config, momFuncs):
        threading.Thread.__init__(self, name="RPCServer")
        self.setDaemon(True)
        self.config = config
        self.momFuncs = momFuncs
        self.logger = logging.getLogger('mom.RPCServer')
        self.server = None
        self.start()

    def thread_ok(self):
        if self.server is None:
            return True
        return self.is_alive()

    def create_server(self):
        try:
            unix_port = None
            port = self.config.getint('main', 'rpc-port')
        except ValueError:
            port = None
            unix_port = self.config.get('main', 'rpc-port')
            self.logger.info("Using unix socket "+unix_port)

        if unix_port is None and (port is None or port < 0):
            return None

        if unix_port:

# Path: mom/unixrpc.py
# class UnixXmlRpcServer(socketserver.UnixStreamServer,
#                        xmlrpc_server.SimpleXMLRPCDispatcher):
#     address_family = socket.AF_UNIX
#     allow_address_reuse = True
# 
#     def __init__(self, sock_path, request_handler=UnixXmlRpcHandler,
#                  logRequests=0):
#         if os.path.exists(sock_path):
#             os.unlink(sock_path)
#         self.logRequests = logRequests
#         xmlrpc_server.SimpleXMLRPCDispatcher.__init__(self,
#                                                            encoding=None,
#                                                            allow_none=1)
#         socketserver.UnixStreamServer.__init__(self, sock_path,
#                                                request_handler)


# Path: mom/RPCServer.py
import threading
import six
from six.moves.xmlrpc_client import Marshaller
from six.moves.xmlrpc_server import SimpleXMLRPCServer
from six.moves.xmlrpc_server import SimpleXMLRPCRequestHandler
from .unixrpc import UnixXmlRpcServer
from .LogUtils import *

    The RPCServer thread provides an API for external programs to interact
    with MOM.
    """
    def __init__(self, config, momFuncs):
        threading.Thread.__init__(self, name="RPCServer")
        self.setDaemon(True)
        self.config = config
        self.momFuncs = momFuncs
        self.logger = logging.getLogger('mom.RPCServer')
        self.server = None
        self.start()

    def thread_ok(self):
        if self.server is None:
            return True
        return self.is_alive()

    def create_server(self):
        try:
            unix_port = None
            port = self.config.getint('main', 'rpc-port')
        except ValueError:
            port = None
            unix_port = self.config.get('main', 'rpc-port')
            self.logger.info("Using unix socket "+unix_port)

        if unix_port is None and (port is None or port < 0):
            return None

        if unix_port:

            self.server = UnixXmlRpcServer(unix_port)