예제 #1
0
def port_manager():
    """An instance of port manager"""

    PortManager._instance = None
    p = PortManager.instance()
    p.console_host = "127.0.0.1"
    return p
예제 #2
0
    def allocate_udp_port(request, response):

        pm = ProjectManager.instance()
        project = pm.get_project(request.match_info["project_id"])
        m = PortManager.instance()
        udp_port = m.get_free_udp_port(project)
        response.set_status(201)
        response.json({"udp_port": udp_port})
예제 #3
0
    def allocate_udp_port(request, response):

        pm = ProjectManager.instance()
        project = pm.get_project(request.match_info["project_id"])
        m = PortManager.instance()
        udp_port = m.get_free_udp_port(project)
        response.set_status(201)
        response.json({"udp_port": udp_port})
예제 #4
0
    def _getDebugData():
        try:
            addrs = [
                "* {}: {}".format(key, val)
                for key, val in psutil.net_if_addrs().items()
            ]
        except UnicodeDecodeError:
            addrs = ["INVALID ADDR WITH UNICODE CHARACTERS"]

        data = """Version: {version}
OS: {os}
Python: {python}
CPU: {cpu}
Memory: {memory}

Networks:
{addrs}
""".format(version=__version__,
           os=platform.platform(),
           python=platform.python_version(),
           memory=psutil.virtual_memory(),
           cpu=psutil.cpu_times(),
           addrs="\n".join(addrs))

        try:
            connections = psutil.net_connections()
        # You need to be root for OSX
        except psutil.AccessDenied:
            connections = None

        if connections:
            data += "\n\nConnections:\n"
            for port in PortManager.instance().tcp_ports:
                found = False
                for open_port in connections:
                    if open_port.laddr[1] == port:
                        found = True
                data += "TCP {}: {}\n".format(port, found)
            for port in PortManager.instance().udp_ports:
                found = False
                for open_port in connections:
                    if open_port.laddr[1] == port:
                        found = True
                data += "UDP {}: {}\n".format(port, found)
        return data
예제 #5
0
    def _getDebugData():
        try:
            addrs = ["* {}: {}".format(key, val) for key, val in psutil.net_if_addrs().items()]
        except UnicodeDecodeError:
            addrs = ["INVALID ADDR WITH UNICODE CHARACTERS"]

        data = """Version: {version}
OS: {os}
Python: {python}
CPU: {cpu}
Memory: {memory}

Networks:
{addrs}
""".format(
            version=__version__,
            os=platform.platform(),
            python=platform.python_version(),
            memory=psutil.virtual_memory(),
            cpu=psutil.cpu_times(),
            addrs="\n".join(addrs)
        )

        try:
            connections = psutil.net_connections()
        # You need to be root for OSX
        except psutil.AccessDenied:
            connections = None

        if connections:
            data += "\n\nConnections:\n"
            for port in PortManager.instance().tcp_ports:
                found = False
                for open_port in connections:
                    if open_port.laddr[1] == port:
                        found = True
                data += "TCP {}: {}\n".format(port, found)
            for port in PortManager.instance().udp_ports:
                found = False
                for open_port in connections:
                    if open_port.laddr[1] == port:
                        found = True
                data += "UDP {}: {}\n".format(port, found)
        return data
예제 #6
0
 def compute(request, response):
     response.template("compute.html",
                       port_manager=PortManager.instance(),
                       project_manager=ProjectManager.instance())
예제 #7
0
 def compute(request, response):
     response.template("compute.html",
                       port_manager=PortManager.instance(),
                       project_manager=ProjectManager.instance())
예제 #8
0
    def network_ports(request, response):

        m = PortManager.instance()
        response.json(m)
예제 #9
0
def port_manager():
    """An instance of port manager"""
    PortManager._instance = None
    p = PortManager.instance()
    p.console_host = "127.0.0.1"
    return p