chiark / gitweb /
Detect internal SDCard readers.
authorDaid <Daid303@gmail.com>
Fri, 17 May 2013 12:01:22 +0000 (14:01 +0200)
committerDaid <Daid303@gmail.com>
Fri, 17 May 2013 12:01:22 +0000 (14:01 +0200)
Cura/util/removableStorage.py

index daf5dbb5e76e69fe7e8ec8a08eafa78365f637d7..1eb807d9a02717b0b30ded376e0a052896ca1633 100644 (file)
@@ -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)))