usbinstall.py: udisks to udisks2 support
This commit is contained in:
parent
bef54500dd
commit
d675d616ea
@ -232,20 +232,32 @@ def get_list():
|
|||||||
|
|
||||||
# Get list form dbus
|
# Get list form dbus
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
ud_manager_obj = bus.get_object('org.freedesktop.UDisks', '/org/freedesktop/UDisks')
|
ud_manager_obj = bus.get_object('org.freedesktop.UDisks2', '/org/freedesktop/UDisks2')
|
||||||
ud_manager = dbus.Interface(ud_manager_obj, 'org.freedesktop.UDisks')
|
ud_manager = dbus.Interface(ud_manager_obj, 'org.freedesktop.DBus.ObjectManager')
|
||||||
for dev in ud_manager.EnumerateDevices():
|
for k,v in ud_manager.GetManagedObjects().iteritems():
|
||||||
device_obj = bus.get_object('org.freedesktop.UDisks', dev)
|
device_block = v.get('org.freedesktop.UDisks2.Block', {})
|
||||||
device_props = dbus.Interface(device_obj, dbus.PROPERTIES_IFACE)
|
device_partitiontable = v.get('org.freedesktop.UDisks2.PartitionTable', {})
|
||||||
# If dev.space > 850 MB
|
device = device_block.get('Device')
|
||||||
if(device_props.Get('org.freedesktop.UDisks.Device', 'PartitionSize')) > 891289600:
|
drive = device_block.get('Drive')
|
||||||
# If dev is removable
|
if not device or not drive or not device_partitiontable:
|
||||||
if(device_props.Get('org.freedesktop.UDisks.Device', 'DeviceIsRemovable')):
|
continue
|
||||||
# Populate the arrays
|
device = bytearray(device).replace(b'\x00', b'').decode('utf-8')
|
||||||
a_path_dev.append(device_props.Get('org.freedesktop.UDisks.Device', 'DeviceFile'))
|
device_drive = bus.get_object('org.freedesktop.UDisks2', drive)
|
||||||
a_dev_model.append(device_props.Get('org.freedesktop.UDisks.Device', 'DriveModel'))
|
try:
|
||||||
|
removable = device_drive.Get('org.freedesktop.UDisks2.Drive', 'Removable', dbus_interface='org.freedesktop.DBus.Properties')
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
size = device_drive.Get('org.freedesktop.UDisks2.Drive', 'Size', dbus_interface='org.freedesktop.DBus.Properties')
|
||||||
|
if removable and size > 891289600 and not device_block.get('ReadOnly') and \
|
||||||
|
not device_block.get('HintSystem') and device_block.get('HintPartitionable'):
|
||||||
|
connectionbus = device_drive.Get('org.freedesktop.UDisks2.Drive', 'ConnectionBus', dbus_interface='org.freedesktop.DBus.Properties')
|
||||||
|
model = device_drive.Get('org.freedesktop.UDisks2.Drive', 'Model', dbus_interface='org.freedesktop.DBus.Properties')
|
||||||
|
vendor = device_drive.Get('org.freedesktop.UDisks2.Drive', 'Vendor', dbus_interface='org.freedesktop.DBus.Properties')
|
||||||
|
if removable:
|
||||||
|
a_path_dev.append(device)
|
||||||
|
a_dev_model.append(vendor + " " + model)
|
||||||
# And add element to comboBox
|
# And add element to comboBox
|
||||||
window.c_usb.addItem(a_path_dev[i] + " " + a_dev_model[i])
|
window.c_usb.addItem(a_dev_model[i] + " (" + "{0:.2f}".format(size / 1024.0 / 1024.0 / 1024.0) + " GiB)")
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
# First dev is default
|
# First dev is default
|
||||||
|
Loading…
Reference in New Issue
Block a user