media/tools/constrained_network_server/cns.py
def _GetConstrainedPort(self, f=None, bandwidth=None, latency=None, loss=None,
                          new_port=False, **kwargs):
    """Creates or gets a port with specified network constraints.

    See ServeConstrained() for more details.
    """
    # Validate inputs. isdigit() guarantees a natural number.
    bandwidth = self._ParseIntParameter(
        bandwidth, 'Invalid bandwidth constraint.', lambda x: x > 0)
    latency = self._ParseIntParameter(
        latency, 'Invalid latency constraint.', lambda x: x >= 0)
    loss = self._ParseIntParameter(
        loss, 'Invalid loss constraint.', lambda x: x <= 100 and x >= 0)

    redirect_port = self._options.port
    if self._options.local_server_port:
      redirect_port = self._options.local_server_port

    start_time = time.time()
    # Allocate a port using the given constraints. If a port with the requested
    # key and kwargs already exist then reuse that port.
    constrained_port = self._port_allocator.Get(
        cherrypy.request.remote.ip, server_port=redirect_port,
        interface=self._options.interface, bandwidth=bandwidth, latency=latency,
        loss=loss, new_port=new_port, file=f, **kwargs)

    cherrypy.log('Time to set up port %d = %.3fsec.' %
                 (constrained_port, time.time() - start_time))

    if not constrained_port:
      raise cherrypy.HTTPError(503, 'Service unavailable. Out of ports.')
    return constrained_port
Creates or gets a port with specified network constraints.

    See ServeConstrained() for more details.
    
Creates or gets a port with specified network constraints.
See ServeConstrained() for more details.
Creates or gets a port with specified network constraints . See ServeConstrained () for more details .
def _GetConstrainedPort(self, f=None, bandwidth=None, latency=None, loss=None,
                          new_port=False, **kwargs):
    bandwidth = self._ParseIntParameter(
        bandwidth, 'Invalid bandwidth constraint.', lambda x: x > 0)
    latency = self._ParseIntParameter(
        latency, 'Invalid latency constraint.', lambda x: x >= 0)
    loss = self._ParseIntParameter(
        loss, 'Invalid loss constraint.', lambda x: x <= 100 and x >= 0)
    redirect_port = self._options.port
    if self._options.local_server_port:
      redirect_port = self._options.local_server_port
    start_time = time.time()
    constrained_port = self._port_allocator.Get(
        cherrypy.request.remote.ip, server_port=redirect_port,
        interface=self._options.interface, bandwidth=bandwidth, latency=latency,
        loss=loss, new_port=new_port, file=f, **kwargs)
    cherrypy.log('Time to set up port %d = %.3fsec.' %
                 (constrained_port, time.time() - start_time))
    if not constrained_port:
      raise cherrypy.HTTPError(503, 'Service unavailable. Out of ports.')
    return constrained_port
def _GetConstrainedPort ( self , f = None , bandwidth = None , latency = None , loss = None , new_port = False , ** kwargs ) : bandwidth = self . _ParseIntParameter ( bandwidth , 'Invalid bandwidth constraint.' , lambda x : x > 0 ) latency = self . _ParseIntParameter ( latency , 'Invalid latency constraint.' , lambda x : x >= 0 ) loss = self . _ParseIntParameter ( loss , 'Invalid loss constraint.' , lambda x : x <= 100 and x >= 0 ) redirect_port = self . _options . port if self . _options . local_server_port : redirect_port = self . _options . local_server_port start_time = time . time ( ) constrained_port = self . _port_allocator . Get ( cherrypy . request . remote . ip , server_port = redirect_port , interface = self . _options . interface , bandwidth = bandwidth , latency = latency , loss = loss , new_port = new_port , file = f , ** kwargs ) cherrypy . log ( 'Time to set up port %d = %.3fsec.' % ( constrained_port , time . time ( ) - start_time ) ) if not constrained_port : raise cherrypy . HTTPError ( 503 , 'Service unavailable. Out of ports.' ) return constrained_port
Creates or gets a port with specified network constraints.
Creates or gets a port with specified network constraints .
"""Creates or gets a port with specified network constraints.

    See ServeConstrained() for more details.
    """ # Validate inputs. isdigit() guarantees a natural number. # Allocate a port using the given constraints. If a port with the requested # key and kwargs already exist then reuse that port.
self
f
bandwidth
latency
loss
new_port