aboutsummaryrefslogtreecommitdiffstats
path: root/lib/isodumper.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/isodumper.py')
-rw-r--r--lib/isodumper.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index 55b1193..ee1c8bc 100644
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -27,9 +27,10 @@
# ensure we're using the latest build, if called from our build environment
import sys
+import imp
sys.path.insert(0,'../../../build/swig/python')
-reload(sys)
+imp.reload(sys)
sys.setdefaultencoding("utf-8")
###########
# imports #
@@ -108,7 +109,7 @@ class UDisks2(object):
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)):
+ 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:
@@ -130,10 +131,10 @@ class UDisks2(object):
re_drive = re.compile('(?P<path>.*?/drives/(?P<id>.*))')
re_block = re.compile('(?P<path>.*?/block_devices/(?P<id>.*))')
devs= [m.groupdict() for m in
- [re_drive.match(path) for path in objects.keys()]
+ [re_drive.match(path) for path in list(objects.keys())]
if m]
blocks = [m.groupdict() for m in
- [re_block.match(path) for path in objects.keys()]
+ [re_block.match(path) for path in list(objects.keys())]
if m]
list=[]
@@ -165,11 +166,11 @@ class UDisks2(object):
'options':','.join(mount_options)
},
dbus_interface=self.FILESYSTEM)
- return unicode(r)
+ return str(r)
except:
# May be already mounted, check
mp = self.node_mountpoint(str(device_node_path))
- print mp, sys.exc_info()[0]
+ print(mp, sys.exc_info()[0])
if mp is None:
raise ValueError(sys.exc_info()[0])
return mp
@@ -454,7 +455,7 @@ class IsoDumper(object):
message = _('Error, umount ')+mount[0]+_(' returned ')+str(retcode)
self.logger(message)
self.emergency(message)
- except OSError, e:
+ except OSError as e:
message = _('Execution failed: ')+str(e)
self.logger(message)
self.emergency(message)
@@ -490,7 +491,7 @@ class IsoDumper(object):
self.progress.setEnabled()
self.progress.setLabel(_('Writing ')+source.split('/')[-1]+_(' to ')+target.split('/')[-1])
self.logger(_('Executing copy from ')+source+_(' to ')+target)
- steps=range(0, b+1, b/100)
+ steps=list(range(0, b+1, b/100))
steps.append(b)
indice=1
written=0
@@ -498,7 +499,7 @@ class IsoDumper(object):
while ncuts <= 100:
bs=bs/2
ncuts=b/bs
- for i in xrange(0,ncuts+1):
+ for i in range(0,ncuts+1):
try:
buf=ifc.read(bs)
except:
@@ -543,7 +544,7 @@ class IsoDumper(object):
self.progress.setEnabled()
self.progress.setLabel(_('Checking ')+target.split('/')[-1])
self.progress.setValue(0)
- steps=range(0, b+1, b/100)
+ steps=list(range(0, b+1, b/100))
steps.append(b)
indice=0
checked=0
@@ -552,7 +553,7 @@ class IsoDumper(object):
ncuts=b/1024
try:
with open(target, 'rb') as f:
- for x in xrange(0,ncuts):
+ for x in range(0,ncuts):
block = f.read(1024)
sha1func.update(block)
md5func.update(block)
@@ -685,7 +686,7 @@ class IsoDumper(object):
logfile.write(self.logview.logText())
logfile.close()
- print self.logview.logText()
+ print(self.logview.logText())
def logger(self, text):
self.logview.appendLines(text+"\n")
@@ -698,7 +699,7 @@ class IsoDumper(object):
# self.chooser.set_tooltip_text(self.img_name)
def help_dialog(self):
- print "Help 2"
+ print("Help 2")
info = Info(_("IsoDumper"),0,_("Mageia IsoDumper\n\
----------------\n\
This GUI program is primarily for safely writing a bootable ISO image to a USB flash drive, an operation devious & potentially hazardous when done by hand. As a bonus, it can also back up the entire previous contents of the flash drive onto the hard disc, and restore the flash drive to its previous state subsequently. It gives also a feature for formatting the USB device.\n\
@@ -958,7 +959,7 @@ The fields of the main window are as follows:\n\
pass
try:
if event.widget() == self.helpbt:
- print "help"
+ print("help")
self.help_dialog()
except:
pass