示例#1
0
 def testIsIp(self):
     from Exscript.util.ipv4 import is_ip
     self.assert_(is_ip('0.0.0.0'))
     self.assert_(is_ip('255.255.255.255'))
     self.assert_(is_ip('1.2.3.4'))
     self.assert_(not is_ip(''))
     self.assert_(not is_ip('1'))
     self.assert_(not is_ip('1.2.3.'))
     self.assert_(not is_ip('.1.2.3'))
     self.assert_(not is_ip('1.23.4'))
     self.assert_(not is_ip('1..3.4'))
示例#2
0
文件: ip.py 项目: souperrod/exscript
def is_ip(string):
    """
    Returns True if the given string is an IPv4 or IPv6 address, False
    otherwise.

    :type  string: string
    :param string: Any string.
    :rtype:  bool
    :return: True if the string is an IP address, False otherwise.
    """
    return ipv4.is_ip(string) or ipv6.is_ip(string)
示例#3
0
文件: ip.py 项目: 0x24bin/exscript
def is_ip(string):
    """
    Returns True if the given string is an IPv4 or IPv6 address, False
    otherwise.

    @type  string: string
    @param string: Any string.
    @rtype:  bool
    @return: True if the string is an IP address, False otherwise.
    """
    return ipv4.is_ip(string) or ipv6.is_ip(string)
示例#4
0
文件: Host.py 项目: keedhost/exscript
    def set_address(self, address):
        """
        Set the address of the remote host the is contacted, without
        changing hostname, username, password, protocol, and TCP port
        number.
        This is the actual address that is used to open the connection.

        @type  address: string
        @param address: A hostname or IP name.
        """
        if is_ip(address):
            self.address = clean_ip(address)
        else:
            self.address = address
示例#5
0
文件: Host.py 项目: keedhost/exscript
def _is_ip(string):
    # Adds IPv6 support.
    return ':' in string or is_ip(string)
示例#6
0
文件: ip.py 项目: souperrod/exscript
def _call_func(funcname, ip, *args):
    if ipv4.is_ip(ip):
        return ipv4.__dict__[funcname](ip, *args)
    elif ipv6.is_ip(ip):
        return ipv6.__dict__[funcname](ip, *args)
    raise ValueError('neither ipv4 nor ipv6: ' + repr(ip))
示例#7
0
文件: ip.py 项目: 0x24bin/exscript
def _call_func(funcname, ip, *args):
    if ipv4.is_ip(ip):
        return ipv4.__dict__[funcname](ip, *args)
    elif ipv6.is_ip(ip):
        return ipv6.__dict__[funcname](ip, *args)
    raise ValueError('neither ipv4 nor ipv6: ' + repr(ip))