diff options
Diffstat (limited to 'lib/isodumper.py')
-rwxr-xr-x | lib/isodumper.py | 66 |
1 files changed, 5 insertions, 61 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py index 4cc8bcb..6a203f7 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -62,7 +62,6 @@ class NoUDisks2(Exception): class UDisks2(object): BLOCK = 'org.freedesktop.UDisks2.Block' - FILESYSTEM = 'org.freedesktop.UDisks2.Filesystem' DRIVE = 'org.freedesktop.UDisks2.Drive' def __init__(self): @@ -75,53 +74,6 @@ class UDisks2(object): raise NoUDisks2() raise - def node_mountpoint(self,node): - - def de_mangle(raw): - return raw.replace('\\040', ' ').replace('\\011', '\t').replace('\\012', - '\n').replace('\\0134', '\\') - - for line in open('/proc/mounts').readlines(): - line = line.split() - if line[0] == node: - return de_mangle(line[1]) - return None - - def device(self, device_node_path): - device_node_path = os.path.realpath(device_node_path) - devname = device_node_path.split('/')[-1] - - # First we try a direct object path - bd = self.bus.get_object('org.freedesktop.UDisks2', - '/org/freedesktop/UDisks2/block_devices/%s'%devname) - try: - device = bd.Get(self.BLOCK, 'Device', - dbus_interface='org.freedesktop.DBus.Properties') - device = bytearray(device).replace(b'\x00', b'').decode('utf-8') - except: - device = None - - if device == device_node_path: - return bd - - # Enumerate all devices known to UDisks2 - devs = self.bus.get_object('org.freedesktop.UDisks2', - '/org/freedesktop/UDisks2/block_devices') - xml = devs.Introspect(dbus_interface='org.freedesktop.DBus.Introspectable') - for dev in re.finditer(r'name=[\'"](.+?)[\'"]', type('')(xml)): - bd = self.bus.get_object('org.freedesktop.UDisks2', - '/org/freedesktop/UDisks2/block_devices/%s2'%dev.group(1)) - try: - device = bd.Get(self.BLOCK, 'Device', - dbus_interface='org.freedesktop.DBus.Properties') - device = bytearray(device).replace(b'\x00', b'').decode('utf-8') - except: - device = None - if device == device_node_path: - return bd - - raise ValueError(_('%r not known to UDisks2')%device_node_path) - def find_devices(self): proxy = self.bus.get_object("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2") iface = dbus.Interface(proxy, "org.freedesktop.UDisks2") @@ -138,15 +90,17 @@ class UDisks2(object): list=[] for dev in devs: - dev_obj =objects[dev['path']]['org.freedesktop.UDisks2.Drive'] + dev_obj =objects[dev['path']][DRIVE] if (dev_obj['ConnectionBus'] == 'usb' or dev_obj['ConnectionBus'] == 'sdio') and \ (dev_obj['Removable'] == 1 or dev_obj['MediaRemovable'] == 1 ): item=[] vend = dev_obj['Vendor'] name = dev_obj['Model'] for block in blocks: - if dev['path'] == objects[block['path']]['org.freedesktop.UDisks2.Block']['Drive']: - path = '/dev/'+block['path'].split('/')[-1] + if dev['path'] == objects[block['path']][BLOCK]['Drive']: + dev_name = block['path'].split('/')[-1] + path = ''.join([i for i in dev_name if not i.isdigit()]) + break size = dev_obj['Size'] item.append(vend+" "+name) item.append(path) @@ -154,16 +108,6 @@ class UDisks2(object): list.append(item) return list - def drive_for_device(self, device): - drive = device.Get(self.BLOCK, 'Drive', - dbus_interface='org.freedesktop.DBus.Properties') - return self.bus.get_object('org.freedesktop.UDisks2', drive) - - def eject(self, device_node_path): - drive = self.drive_for_device(self.device(device_node_path)) - drive.Eject({'auth.no_user_interaction':True}, - dbus_interface=self.DRIVE) - class Info(object): def __init__(self,title,richtext,text): self.title=title |