Fix OSXRemovableDevicePlugin so it works properly on OSX

This commit is contained in:
Arjen Hiemstra 2015-08-04 15:39:58 +02:00
parent 543c58d57a
commit 26aa78c3b9

View file

@ -13,8 +13,8 @@ import os
import plistlib import plistlib
## Support for removable devices on Mac OSX ## Support for removable devices on Mac OSX
class OSXRemovableDrives(RemovableDrivePlugin.RemovableDrivePlugin): class OSXRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
def run(self): def checkRemovableDrives(self):
drives = {} drives = {}
p = subprocess.Popen(["system_profiler", "SPUSBDataType", "-xml"], stdout=subprocess.PIPE) p = subprocess.Popen(["system_profiler", "SPUSBDataType", "-xml"], stdout=subprocess.PIPE)
plist = plistlib.loads(p.communicate()[0]) plist = plistlib.loads(p.communicate()[0])
@ -41,6 +41,8 @@ class OSXRemovableDrives(RemovableDrivePlugin.RemovableDrivePlugin):
volume = vol["mount_point"] volume = vol["mount_point"]
drives[volume] = os.path.basename(volume) drives[volume] = os.path.basename(volume)
return drives
def performEjectDevice(self, device): def performEjectDevice(self, device):
p = subprocess.Popen(["diskutil", "eject", path], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(["diskutil", "eject", path], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = p.communicate() output = p.communicate()