Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Additional check for wireless #9

Closed
clburlison opened this issue Feb 18, 2016 · 2 comments
Closed

Additional check for wireless #9

clburlison opened this issue Feb 18, 2016 · 2 comments
Milestone

Comments

@clburlison
Copy link
Owner

If wireless is disabled and preference is to leave it disabled we should write that to status and exit(1).

Tied to #3

@clburlison clburlison added this to the 0.0.2 milestone Feb 18, 2016
@clburlison
Copy link
Owner Author

This code should be ready to be applied.

import objc
import subprocess
from Foundation import NSBundle
objc.loadBundle('CoreWLAN',
                 bundle_path='/System/Library/Frameworks/CoreWLAN.framework',
                 module_globals=globals())
iface_name = CWInterface.interfaceNames()

# This handles a case where we have no wireless interface
# and the return value is None
if iface_name:
    # The first interface can be assumed to be the airport card
    iface_name = iface_name.itervalues().next()
    command = ['/usr/sbin/networksetup', '-getairportpower', 
              iface_name]
    proc = subprocess.Popen(command, shell=False,stdout=subprocess.PIPE)
    interface_output = (proc.communicate()[0].replace('\n', '')
                       .split(":")[1].replace(' ', ''))
    print interface_output
else:
    print None

@clburlison
Copy link
Owner Author

This was fixed resolved with 41da466

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant