Commits

Ben Bass committed 6ca83ef

scripts to perform os x driver loading / unloading

Comments (0)

Files changed (3)

scripts/ftdi_osx_driver_reload

+#!/usr/bin/env python
+import sys
+if sys.platform != 'darwin':
+    raise SystemExit("{} runs on Mac OS X only".format(sys.argv[0]))
+
+from subprocess import check_output, CalledProcessError
+
+if check_output(['sw_vers', '-productVersion']).strip() >= '10.9.0':
+    command = ['kextload', '-bundle-id', 'com.apple.driver.AppleUSBFTDI']
+else:
+    command = ['kextload', '/System/Library/Extensions/FTDIUSBSerialDriver.kext']
+
+print("Loading the OS FTDI driver. This may require the sudo password")
+try:
+    check_output(['sudo'] + command)
+except CalledProcessError as e:
+    print(e)
+    raise SystemExit("Command failed; the module could not be loaded")
+else:
+    print("Complete.")

scripts/ftdi_osx_driver_unload

+#!/usr/bin/env python
+import sys
+if sys.platform != 'darwin':
+    raise SystemExit("{} runs on Mac OS X only".format(sys.argv[0]))
+
+from subprocess import check_output, CalledProcessError
+
+if check_output(['sw_vers', '-productVersion']).strip() >= '10.9.0':
+    command = ['kextunload', '-bundle-id', 'com.apple.driver.AppleUSBFTDI']
+else:
+    command = ['kextunload', '/System/Library/Extensions/FTDIUSBSerialDriver.kext']
+
+print("Unloading the OS FTDI driver. This may require the sudo password")
+try:
+    check_output(['sudo'] + command)
+except CalledProcessError as e:
+    print(e)
+    raise SystemExit("Command failed; likely the module is already unloaded")
+else:
+    print("Complete.")
     author_email="benbass@codedstructure.net",
     url="http://bitbucket.org/codedstructure/pylibftdi",
     packages=["pylibftdi", "pylibftdi.examples"],
+    scripts=["scripts/ftdi_osx_driver_reload",
+             "scripts/ftdi_osx_driver_unload"],
     classifiers=[
         "Development Status :: 4 - Beta",
         "Environment :: Console",