From: Daid Date: Fri, 17 May 2013 12:01:22 +0000 (+0200) Subject: Detect internal SDCard readers. X-Git-Tag: 13.05^2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9b26b5b9330fd5fa1462e9d1792e3c9f8bc589ad;p=cura.git Detect internal SDCard readers. --- diff --git a/Cura/util/removableStorage.py b/Cura/util/removableStorage.py index daf5dbb5..1eb807d9 100644 --- a/Cura/util/removableStorage.py +++ b/Cura/util/removableStorage.py @@ -88,6 +88,21 @@ def getPossibleSDcardDrives(): if 'mount_point' in vol: volume = vol['mount_point'] drives.append((os.path.basename(volume), volume, os.path.basename(volume))) + + p = subprocess.Popen(['system_profiler', 'SPCardReaderDataType', '-xml'], stdout=subprocess.PIPE) + xml = ElementTree.fromstring(p.communicate()[0]) + p.wait() + + xml = _parseStupidPListXML(xml) + for entry in xml: + if '_items' in entry: + for item in entry['_items']: + for dev in item['_items']: + if 'removable_media' in dev and dev['removable_media'] == 'yes' and 'volumes' in dev and len(dev['volumes']) > 0: + for vol in dev['volumes']: + if 'mount_point' in vol: + volume = vol['mount_point'] + drives.append((os.path.basename(volume), volume, os.path.basename(volume))) else: for volume in glob.glob('/media/*'): drives.append((os.path.basename(volume), volume, os.path.basename(volume)))