当前位置: 首页>>代码示例>>Python>>正文


Python IPy类代码示例

本文整理汇总了Python中IPy的典型用法代码示例。如果您正苦于以下问题:Python IPy类的具体用法?Python IPy怎么用?Python IPy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IPy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testRandomValuesv6

 def testRandomValuesv6(self):
     for i in range(testloops):
         question = ((random.randrange(0x7fffffff) + random.randrange(0x7fffffff)) +
                     ((random.randrange(0x7fffffff) + random.randrange(0x7fffffff)) << 32) +
                     ((random.randrange(0x7fffffff) + random.randrange(0x7fffffff)) << 64) +
                     ((random.randrange(0x7fffffff) + random.randrange(0x7fffffff)) << 96))
         self.assertEqual(IPy.parseAddress(IPy.intToIp(question, 6)), (question, 6), hex(question))
开发者ID:Guojian,项目名称:python-ipy,代码行数:7,代码来源:test_IPy.py

示例2: mod_change_cache

def mod_change_cache(zona=None, rr=None, rtype=None, ttl=1800, data=None, action=None, username=None, del_id=None, operation=None):
    """Modify the publish queue"""
    zone_id = zones.select().where(zones.zone == zona).get()
    if rtype == "A" or rtype == "NS":
        try:
            IPy.parseAddress(data)
        except ValueError:
            return False

    if operation == "add_unpub":
        for item in [zona, rr, rtype, ttl, data, action, operation]:
            if item is None:
                return False

        if change_cache.select().where(change_cache.rr == rr,
                                       change_cache.zone_id == zone_id,
                                       change_cache.type == rtype,
                                       change_cache.data == data,
                                       change_cache.action == "add").count():
                return True
        change_cache.create(username=username,
                            rr=rr,
                            zone_id=zone_id,
                            type=rtype,
                            ttl=ttl,
                            data=data,
                            action=action)
        return True

    elif operation == "del_unpub":
        delete_query = change_cache.delete().where((change_cache.id == del_id) & (change_cache.zone_id == zone_id))
        delete_query.execute()
        return True
开发者ID:the-elven-archer,项目名称:bind_manager,代码行数:33,代码来源:main.py

示例3: testCheckNetmaskOk

 def testCheckNetmaskOk(self):
     """Legal Netmasks should be allowed."""
     self.assertFalse(IPy._checkNetmask(0xffffffff, 32))
     self.assertFalse(IPy._checkNetmask(0xffffff00, 32))
     self.assertFalse(IPy._checkNetmask(0xffff0000, 32))
     self.assertFalse(IPy._checkNetmask(0xff000000, 32))
     self.assertFalse(IPy._checkNetmask(0, 32))
开发者ID:LTD-Beget,项目名称:python-ipy,代码行数:7,代码来源:test_IPy.py

示例4: multi_ipcheck

def multi_ipcheck(form, field):
    error = []
    for x in field.data.split():
        try:
            IPy.parseAddress(x)
        except ValueError:
            error.append( x )

    if error:
        raise ValidationError( _('Error IP: %s') % error )
开发者ID:alayasix,项目名称:LuoYunCloud,代码行数:10,代码来源:forms.py

示例5: testCheckNetmaskOk

 def testCheckNetmaskOk(self):
     """Legal Netmasks should be allowed."""
     self.failIf(IPy._checkNetmask(0xFFFFFFFFL, 32))
     self.failIf(IPy._checkNetmask(0xFFFFFF00L, 32))
     self.failIf(IPy._checkNetmask(0xFFFF0000L, 32))
     self.failIf(IPy._checkNetmask(0xFF000000L, 32))
     self.failIf(IPy._checkNetmask(0, 32))
开发者ID:ingenarius,项目名称:ipall,代码行数:7,代码来源:test_IPy.py

示例6: testCount1Bits

 def testCount1Bits(self):
     self.assertEqual(IPy._count1Bits(0), 0)
     self.assertEqual(IPy._count1Bits(0xF), 4)
     self.assertEqual(IPy._count1Bits(0x10), 5)
     self.assertEqual(IPy._count1Bits(0xFF), 8)
     self.assertEqual(IPy._count1Bits(0xFFFF), 16)
     self.assertEqual(IPy._count1Bits(0xFFFFFFFFL), 32)
     self.assertEqual(IPy._count1Bits(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL), 128)
开发者ID:ingenarius,项目名称:ipall,代码行数:8,代码来源:test_IPy.py

示例7: makeIpPool

    def makeIpPool(self, startIP, lastIP):
        '''生产 IP 地址池'''
        IPver = 6 if self.IPv6 else 4
        intIP = lambda ip: IPy.IP(ip).int()
        ipPool = {IPy.intToIp(ip, IPver) for ip in range(intIP(startIP), intIP(lastIP)+1)}

        return {ip for ip in ipPool if self.isUnIP(ip)}
开发者ID:wkown,项目名称:pytest33,代码行数:7,代码来源:icmp_scan.py

示例8: check_ip_address

def check_ip_address(address, version=None):
    try:
        _ip, ver = IPy.parseAddress(address)
    except ValueError:
        return False
    if version and version == ver:
        return True
开发者ID:uofis,项目名称:qubes-installer-qubes-os,代码行数:7,代码来源:network.py

示例9: ip_version_validator

def ip_version_validator(value, version, message):
	try:
		ip, v = IPy.parseAddress(value)
	except ValueError:
		raise forms.ValidationError(message)
	if v != version:
		raise forms.ValidationError(message)
开发者ID:wiedi,项目名称:django-netmgt,代码行数:7,代码来源:forms.py

示例10: IP_int_prefixlen

def IP_int_prefixlen(ipnum, prefixlen, version):
    if version == 4:
        width = 32
    else:
        width = 128
    ipnum &= -(1 << (width - prefixlen))
    return IP("{0}/{1}".format(IPy.intToIp(ipnum, version), prefixlen))
开发者ID:Chonghao,项目名称:build-fwunit,代码行数:7,代码来源:ip.py

示例11: address_check

def address_check(address):
    '''
    Check if the IP address is valid.

    :param str address: IP address to check
    :return: tuple of (address, version), where address is cleaned up IP address
             and version is 4 for IPv4 and 6 for IPv6
    :rtype: tuple of (str, int)
    :raises: IPCheckFailed
    '''
    try:
        address_int, version = IPy.parseAddress(address)
    except ValueError:
        raise IPCheckFailed("Invalid IP address: %s" % address)
    address = IPy.intToIp(address_int, version)
    return (address, version)
开发者ID:balamurugana,项目名称:openlmi-scripts,代码行数:16,代码来源:util.py

示例12: creatIpPool

	def creatIpPool(self, startIP, stopIP):
		ipPool = set()
		if self.isV6:
			print "this function is not develop"
		else:
			ipToInt = lambda ip: IPy.IP(ip).int()
			ipPool = {IPy.intToIp(ip, 4) for ip in range(ipToInt(startIP), ipToInt(stopIP)+1)}
		return ipPool
开发者ID:JivaGzw,项目名称:IPscan,代码行数:8,代码来源:icmp.py

示例13: query

 def query(self, sql):
     print "executing sql : " + sql
     self.cur.execute(sql)
     alldata = self.cur.fetchall()
     if alldata:
         for data in alldata:
             eid = IPy.parseAddress(data[0])
             #print eid
             print data[0], data[1]
     return alldata
开发者ID:zhenshengcai,项目名称:xTRController,代码行数:10,代码来源:db_access.py

示例14: increment_range

def increment_range(start_ip, counter):
    """
    Increment IP address by 255 multiple times
    :param start_ip: base IP to be incremented
    :type start_ip: str
    :param counter: how many times do you want to increment the IP by 255
    :return:incremented IP
    """
    incremented_ip_int = IPy.IPint(start_ip).int() + counter * 255
    incremented_ip_str = IPy.intToIp(ip=incremented_ip_int, version=4)
    return incremented_ip_str
开发者ID:xpavli44,项目名称:responder,代码行数:11,代码来源:responder.py

示例15: testKnownValues

 def testKnownValues(self):
     """parsing of known values should give known results"""
     for x in self.okValues:
         (question, answer) = x
         (result, version) = IPy.parseAddress(question)
         self.assertEqual(answer, result, "%r, %r, %r" % (question, answer, result))
开发者ID:ingenarius,项目名称:ipall,代码行数:6,代码来源:test_IPy.py


注:本文中的IPy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。