How do you use PyObjC to disable and on Mac wireless interfaces?

How do you use PyObjC to disable and on Mac wireless interfaces? My research to date has led me to the Cocoa Framework and PyObjC. On the Mac Developer website, I found an example of a wireless management application that demonstrates how to use the Cocoa Framework to turn Mac wireless interfaces on and off here . This example shows that CWInterface in the CoreWLAN Framework is necessary to complete the task of disabling and using the Mac wireless interface . However, PyObjC does not seem to include the Cocoa CoreWLAN Framework in its packaging here . Any thoughts on how to complete this task? Can I implement my own PyObjc objects to call the CoreWLAN Framework, and if so, what would be a good resource on how to do this? Thank you for your time! Something helps.

+5
cocoa wireless macos pyobjc
source share
1 answer

You can download the framework manually using:

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

Classes in the structure are now available in the module global dictionary.

Get wireless with

 iface = CWInterface.interface() 

Then you can turn the power on or off with:

 iface.setPower_error_(True, None) 

or

 iface.setPower_error_(False, None) 

PS I will add this structure in a future version, for the reason that it is not available at the moment, because I did not know that this is a public structure.

+5
source share

All Articles