aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpapoteur-mga <yves.brungard_git@gadz.org>2014-05-01 20:55:21 +0200
committerpapoteur-mga <yves.brungard_git@gadz.org>2014-05-01 20:55:21 +0200
commit39db4f37bf7cf560f60629175fb6263f017c3c41 (patch)
treeca84f1b87c3353b2b8b9789ae836c4262fe0b3cb /lib
parentf3d70c61c957dee0cd4ebeb84c0651edced22565 (diff)
downloadisodumper-39db4f37bf7cf560f60629175fb6263f017c3c41.tar
isodumper-39db4f37bf7cf560f60629175fb6263f017c3c41.tar.gz
isodumper-39db4f37bf7cf560f60629175fb6263f017c3c41.tar.bz2
isodumper-39db4f37bf7cf560f60629175fb6263f017c3c41.tar.xz
isodumper-39db4f37bf7cf560f60629175fb6263f017c3c41.zip
Integration of find_devices in the main file.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/isodumper.py41
1 files changed, 33 insertions, 8 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index f125977..e2ae2f5 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -24,11 +24,35 @@
import gtk
import gtk.glade
import gobject
-from subprocess import Popen,PIPE,call
import os
import io
import gettext
from gettext import gettext as _
+from subprocess import call
+
+def find_devices():
+ import dbus
+ bus = dbus.SystemBus()
+ proxy = bus.get_object("org.freedesktop.UDisks", "/org/freedesktop/UDisks")
+ iface = dbus.Interface(proxy, "org.freedesktop.UDisks")
+ devs=iface.EnumerateDevices()
+ list=[]
+
+ for dev in devs:
+ dev_obj = bus.get_object("org.freedesktop.UDisks", dev)
+ dev = dbus.Interface(dev_obj, "org.freedesktop.DBus.Properties")
+ item=[]
+ if str(dev.Get('', 'DriveConnectionInterface')) == 'usb' and not str(dev.Get('', 'PartitionType')) and str(dev.Get('', 'DeviceIsMediaAvailable')) == '1':
+ vend = str(dev.Get('', 'DriveVendor'))
+ path = str(dev.Get('', 'DeviceFile'))
+ name = str(dev.Get('', 'DriveModel'))
+ size = str(dev.Get('', 'DeviceSize'))
+ item.append(vend+" "+name)
+ item.append(path)
+ item.append(size)
+ list.append(item)
+ print list
+ return list
class IsoDumper:
@@ -93,25 +117,26 @@ class IsoDumper:
self.window.show_all()
# make sure we have a target device
self.get_devices()
+
+
def get_devices(self):
dialog = self.wTree.get_widget("nodev_dialog")
- list = Popen(["/usr/lib/isodumper/find_devices"], stdout=PIPE).communicate()[0]
- while not len(list):
+ list=find_devices()
+ while len(list)==0:
exit_dialog=dialog.run()
- list = Popen(["/usr/lib/isodumper/find_devices"], stdout=PIPE).communicate()[0]
+ list = find_devices()
if (exit_dialog==2) :
dialog.destroy()
exit(0)
self.combo = self.wTree.get_widget("device_combobox")
- list = list.strip().split('\n')
- for item in list:
- name,path,size = item.split(',')
+ for name, path, size in list:
self.deviceSize=size
- # convert in Mbytes
+ # convert in Mbytes
sizeM=str(int(size)/(1024*1024))
self.combo.append_text(name+' ('+path.lstrip()+') '+sizeM+_('Mb'))
dialog.destroy()
+
def device_selected(self, widget):
write_button = self.wTree.get_widget("write_button")
write_button.set_sensitive(True)