aboutsummaryrefslogtreecommitdiffstats
path: root/lib/find_devices
diff options
context:
space:
mode:
Diffstat (limited to 'lib/find_devices')
-rwxr-xr-xlib/find_devices20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/find_devices b/lib/find_devices
new file mode 100755
index 0000000..6a56c03
--- /dev/null
+++ b/lib/find_devices
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+proxy = bus.get_object("org.freedesktop.UDisks", "/org/freedesktop/UDisks")
+iface = dbus.Interface(proxy, "org.freedesktop.UDisks")
+
+devs = iface.EnumerateDevices()
+
+for dev in devs:
+ dev_obj = bus.get_object("org.freedesktop.UDisks", dev)
+ dev = dbus.Interface(dev_obj, "org.freedesktop.DBus.Properties")
+
+ if str(dev.Get('', 'DriveConnectionInterface')) == 'usb' and not str(dev.Get('', 'PartitionType')) and str(dev.Get('', 'DeviceIsMediaAvailable')) == '1':
+ path = str(dev.Get('', 'DeviceFile'))
+ vend = str(dev.Get('', 'DriveVendor'))
+ model = str(dev.Get('', 'DriveModel'))
+ print vend + ' ' + model + ', ' +path