aboutsummaryrefslogtreecommitdiffstats
path: root/lib/find_devices
blob: 0b32eac1813b2c8f640f2e37ade29e26577a7c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/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'))
		size = str(dev.Get('', 'DeviceSize'))
		print vend + ' ' + model + ', ' +path+', ' + size