diff options
Diffstat (limited to 'lib/isodumper.py')
-rwxr-xr-x | lib/isodumper.py | 45 |
1 files changed, 6 insertions, 39 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py index 8af078e..4fae067 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -42,7 +42,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): @@ -55,41 +54,6 @@ class UDisks2(object): raise NoUDisks2() raise - 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(u'')(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") @@ -113,8 +77,11 @@ class UDisks2(object): 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()]) + path = '/dev/' + path + break size = dev_obj['Size'] item.append(vend+" "+name) item.append(path) @@ -132,7 +99,7 @@ class IsoDumper: def __init__(self,user): APP="isodumper" DIR="/usr/share/locale" - RELEASE="v0.47" + RELEASE="v0.48" gettext.bindtextdomain(APP, DIR) gettext.textdomain(APP) |