def _check_ports(self): if not 'port' in self: self['port'] = self.random_port(self['nb_ports']) else: port = self['port'] if not isinstance(port, list): port = [port] in_use = [str(p) for p in port if util.is_port_in_use(p)] if in_use: raise Exception( 'Some ports were already in use: %s.' % ', '.join(in_use))
def find_nearest_port(port): while util.is_port_in_use(port): port += 1 return port