有什么方法可以使用Python访问OS X wi-fi数据吗? (例如,信号强度) [英] Is there any way to access OS X wi-fi data using Python? (Signal strength, for example)

查看:181
本文介绍了有什么方法可以使用Python访问OS X wi-fi数据吗? (例如,信号强度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,是否有可能使用任何Python工具来轮询OS X中的wi-fi信号强度.我的大部分搜索只是针对Linux推出了Python工具,而对于OS X却没有.

I am just curious whether it would be possible to use any Python tools to poll wi-fi signal strength in OS X. Most of my searches are just yielding Python tools for Linux, but none for OS X.

如果没有,是否还有其他方法可以通过编程方式获取此类数据?

If not, are there any other ways to get such data programmatically?

推荐答案

The answer to this question describes how to load the CoreWLAN framework. Once you've done that, you can use the CWInterface class to find the RSSI, amongst other stats:

import objc
objc.loadBundle('CoreWLAN',
                bundle_path='/System/Library/Frameworks/CoreWLAN.framework',
                module_globals=globals())

for iname in CWInterface.interfaceNames():
  interface = CWInterface.interfaceWithName_(iname)
  print """
Interface:      %s
SSID:           %s
Transmit Rate:  %s
Transmit Power: %s
RSSI:           %s""" % (iname, interface.ssid(), interface.transmitRate(),
                         interface.transmitPower(), interface.rssi())

请参见 CWInterface文档获取可用属性的完整列表.

See the CWInterface docs for the full list of available properties.

这篇关于有什么方法可以使用Python访问OS X wi-fi数据吗? (例如,信号强度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆