Python socket 模块,if_nameindex() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用socket.if_nameindex()

项目:hakkuframework    作者:4shadoww    | 项目源码 | 文件源码
def get_if_list():
      #return [ i[1] for i in socket.if_nameindex() ]
      return netifaces.interfaces()
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
def get_if_list():
      #return [ i[1] for i in socket.if_nameindex() ]
      return netifaces.interfaces()
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def testInterfaceNameIndex(self):
        interfaces = socket.if_nameindex()
        for index, name in interfaces:
            self.assertIsInstance(index, int)
            self.assertIsInstance(name, str)
            # interface indices are non-zero integers
            self.assertGreater(index, 0)
            _index = socket.if_nametoindex(name)
            self.assertIsInstance(_index, int)
            self.assertEqual(index, _index)
            _name = socket.if_indextoname(index)
            self.assertIsInstance(_name, str)
            self.assertEqual(name, _name)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def testInterfaceNameIndex(self):
        interfaces = socket.if_nameindex()
        for index, name in interfaces:
            self.assertIsInstance(index, int)
            self.assertIsInstance(name, str)
            # interface indices are non-zero integers
            self.assertGreater(index, 0)
            _index = socket.if_nametoindex(name)
            self.assertIsInstance(_index, int)
            self.assertEqual(index, _index)
            _name = socket.if_indextoname(index)
            self.assertIsInstance(_name, str)
            self.assertEqual(name, _name)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def testInterfaceNameIndex(self):
        interfaces = socket.if_nameindex()
        for index, name in interfaces:
            self.assertIsInstance(index, int)
            self.assertIsInstance(name, str)
            # interface indices are non-zero integers
            self.assertGreater(index, 0)
            _index = socket.if_nametoindex(name)
            self.assertIsInstance(_index, int)
            self.assertEqual(index, _index)
            _name = socket.if_indextoname(index)
            self.assertIsInstance(_name, str)
            self.assertEqual(name, _name)
项目:PyQYT    作者:collinsctk    | 项目源码 | 文件源码
def get_if_list():
      #return [ i[1] for i in socket.if_nameindex() ]
      return netifaces.interfaces()