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


Python Interface.name方法代码示例

本文整理汇总了Python中interface.Interface.name方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.name方法的具体用法?Python Interface.name怎么用?Python Interface.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在interface.Interface的用法示例。


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

示例1: iwconfig

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import name [as 别名]
def iwconfig():
    devnull = open(os.devnull, 'w')
    lst = []

    cmd = Popen(['iwconfig'], stdout=PIPE, stderr=devnull)
    for line in cmd.communicate()[0].split('\n\n'):
        tmpiface = Interface(None, None, None, None)
        line = line.strip()

        if len(line) == 0:
            continue

        ifname = re.search('^([A-Za-z0-9]+)', line)
        ifessid = re.search('ESSID:"([A-Za-z0-9]+)"', line)
        ifmode = re.search('Mode:([A-Za-z]+)', line)
        ifbssid = re.search('Access Point: ([0-9:A-F]+)', line)

        if ifname is not None:
            tmpiface.name = ifname.group(1)

            if ifessid is not None:
                tmpiface.essid = ifessid.group(1)

            if ifmode is not None:
                tmpiface.mode = ifmode.group(1)

            if ifbssid is not None:
                tmpiface.bssid = ifbssid.group(1)

            lst.append(tmpiface)

    devnull.close()
    return lst
开发者ID:ShaneHarvey,项目名称:wepcracker,代码行数:35,代码来源:sniffer.py

示例2: get_if_list

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import name [as 别名]
	def get_if_list(self, host):
		"""Get list of host's interfaces"""

		results = NetCrawler.snmp.walk(host.ip, '1.3.6.1.2.1.2.2.1.6')

		if results is not None:
			for result in results:
				for name, val in result:
					interface = str(name).split('1.3.6.1.2.1.2.2.1.6.', 1)[1]
					mac = hex_to_mac(val)

					host.add_mac(mac)

					intf = Interface()
					intf.number = str(name).split('1.3.6.1.2.1.2.2.1.6.', 1)[1]
					intf.mac = hex_to_mac(val)
					host.add_interface(intf)
		
			del interface
			del mac

		del results
		
		results = NetCrawler.snmp.walk(host.ip, '1.3.6.1.2.1.2.2.1.2')

		if results is not None:
			for result in results:
				for name, val in result:
					interface = str(name).split('1.3.6.1.2.1.2.2.1.2.', 1)[1]
					descr = str(val)

					intf = host.get_interface(interface)
					intf.descr = descr

				del interface
				del descr

		del results

		results = NetCrawler.snmp.walk(host.ip, '1.3.6.1.2.1.2.2.1.8')

		if results is not None:
			for result in results:
				for name, val in result:
					interface = str(name).split('1.3.6.1.2.1.2.2.1.8.', 1)[1]
					status = str(val)

					intf = host.get_interface(interface)
					intf.status = status

		del results
		results = NetCrawler.snmp.walk(host.ip, '1.3.6.1.2.1.31.1.1.1.1')

		#print('ifName')
		if results is not None:
			for result in results:
				for name, val in result:
					interface = str(name).split('1.3.6.1.2.1.31.1.1.1.1.', 1)[1]
					if_name = str(val)

					intf = host.get_interface(interface)
					intf.name = if_name
开发者ID:logileifs,项目名称:NetCrawler,代码行数:64,代码来源:netcrawler2.py


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