Tells if a certain protocol is available
434228
def has_protocol(self, name):
    """"""

    return self.query(Protocol).filter(Protocol.name==name).count() != 0
1093943
def is_reachable(self):
        """"""
        if self.verify_reachability and \
                hasattr(self.verify_reachability, '__call__'):
            return self.verify_reachability(host=self.hostname, port=self.port)
        # assume is reachable if can't verify
        return True
57752
def _is_reachable(self, server):
        """"""

        try:
            server['redis'].ping()
            return True
        except UserWarning:
            self._logger.warn('Cannot reach redis server: ' + server['url'])
        except Exception:
            self._logger.warn('Cannot reach redis server: ' + server['url'])

        return False
557663
def _is_valid_endpoint(endpoint):
    """"""
    return any([is_number(endpoint),
                isinstance(endpoint, Timestamp),
                isinstance(endpoint, Timedelta),
                endpoint is None])
1317315
def assert_trade_protocol(event):
    """"""
    assert_datasource_protocol(event)

    assert event.type == DATASOURCE_TYPE.TRADE
    assert isinstance(event.price, numbers.Real)
    assert isinstance(event.volume, numbers.Integral)
    assert isinstance(event.dt, datetime)
500973
def assert_datasource_protocol(event):
    """"""

    assert event.type in DATASOURCE_TYPE

    # Done packets have no dt.
    if not event.type == DATASOURCE_TYPE.DONE:
        assert isinstance(event.dt, datetime)
        assert event.dt.tzinfo == pytz.utc
282552
function isExternal(href) {
    try {
        return Boolean(url.parse(href).protocol) && !isDataURI(href);
    } catch(err) {
        return false;
    }
}
181853
def check_protocol(mcs, handler):
        
        protocol_info = mcs.PROTOCOL_INFO
        protocol_version = (protocol_info.major, protocol_info.minor)
        protocol_flags = protocol_info.flags

        # Check if minimum protocol version requirement is met
        min_protocol_version = getattr(handler, '_minimum_katcp_version', None)
        protocol_version_ok = (min_protocol_version is None or
                               protocol_version >= min_protocol_version)

        # Check if required optional protocol flags are present
        required_katcp_protocol_flags = getattr(
            handler, '_has_katcp_protocol_flags', None)
        protocol_flags_ok = (
            required_katcp_protocol_flags is None or
            all(flag in protocol_flags
                for flag in required_katcp_protocol_flags))

        return protocol_version_ok and protocol_flags_ok
489807
function allowed(packet) {
    if (!packet) return false;

    if (uv.position === 'inactive' || (!uv.received(packet.id) && ordered)) {
      queue.push(packet);
      return false;
    }

    return true;
  }
623462
def _check_servers(self):
        """"""
        new_servers = []

        def check_format(server):
            if server.scheme not in ["thrift", "http", "https"]:
                raise RuntimeError("Unable to recognize protocol: \"%s\"" % _type)

            if server.scheme == "thrift":
                if not thrift_connect:
                    raise RuntimeError("If you want to use thrift, please install thrift. \"pip install thrift\"")
                if server.port is None:
                    raise RuntimeError("If you want to use thrift, please provide a port number")

            new_servers.append(server)

        for server in self.servers:
            if isinstance(server, (tuple, list)):
                if len(list(server)) != 3:
                    raise RuntimeError("Invalid server definition: \"%s\"" % repr(server))
                _type, host, port = server
                server = urlparse('%s://%s:%s' % (_type, host, port))
                check_format(server)
            elif isinstance(server, six.string_types):
                if server.startswith(("thrift:", "http:", "https:")):
                    server = urlparse(server)
                    check_format(server)
                    continue
                else:
                    tokens = [t for t in server.split(":") if t.strip()]
                    if len(tokens) == 2:
                        host = tokens[0]
                        try:
                            port = int(tokens[1])
                        except ValueError:
                            raise RuntimeError("Invalid port: \"%s\"" % tokens[1])

                        if 9200 <= port <= 9299:
                            _type = "http"
                        elif 9500 <= port <= 9599:
                            _type = "thrift"
                        else:
                            raise RuntimeError("Unable to recognize port-type: \"%s\"" % port)

                        server = urlparse('%s://%s:%s' % (_type, host, port))
                        check_format(server)

        self.servers = new_servers
832399
def _check_ip_available(ip_addr):
    '''
    
    '''
    for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=True)):
        vm_config = vm_details['config']
        if ip_addr in vm_config['ip_address'] or vm_config['ip_address'] == ip_addr:
            log.debug('IP "%s" is already defined', ip_addr)
            return False

    log.debug('IP \'%s\' is available to be defined', ip_addr)
    return True
262757
def validate(self):
		
		if self.implemented_protocol_version != self.protocol_version:
			raise OmapiError("protocol mismatch")
		if self.implemented_header_size != self.header_size:
			raise OmapiError("header size mismatch")
934216
async def on_capability_sasl_available(self, value):
        
        if value:
            self._sasl_mechanisms = value.upper().split(',')
        else:
            self._sasl_mechanisms = None

        if self.sasl_mechanism == 'EXTERNAL' or (self.sasl_username and self.sasl_password):
            if self.sasl_mechanism == 'EXTERNAL' or puresasl:
                return True
            self.logger.warning('SASL credentials set but puresasl module not found: not initiating SASL authentication.')
        return False
5167
def _supported_rule(protocol, ethertype):
        """"""
        if not protocol or protocol not in utils.SUPPORTED_SG_PROTOCOLS:
            return False

        if ethertype != n_const.IPv4:
            return False

        return True
18953
def is_available(self):
        
        if self.scheme in NOOP_PROTOCOLS:
            return True

        if not self.port:
            raise RuntimeError('port is required')

        s = socket.socket()
        try:
            s.connect((self.host, self.port))
        except Exception:
            return False
        else:
            return True
1200463
def available(self, context):
	
		
		
		if self.__available is None:
			avail = False
			name = context.resolve(self.__name)
			for box in self.__box_list():
				if box["name"] == name and box["version"] == "0":
					avail = True
					break
			self.__available = avail
		return self.__available
10462
def check_protocol(protocol)
      klass = Header.get_header_class_by_name(protocol)
      raise ArgumentError, "unknown #{protocol} protocol" if klass.nil?

      klass
    end