aboutsummaryrefslogtreecommitdiffstats
path: root/lib/isodumper.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/isodumper.py')
-rwxr-xr-xlib/isodumper.py58
1 files changed, 17 insertions, 41 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index c84baf5..e84285f 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -54,7 +54,6 @@ from subprocess import call, Popen, PIPE
from pydbus import SystemBus
from gi.repository import GLib
-
class NoUDisks2(Exception):
pass
@@ -289,16 +288,28 @@ class IsoDumper(object):
if success:
#Writing step
#Dump mode
- iface.do_write(source, target)
- print("Ecriture en cours")
- while iface.progress < 100 :
- self.progress.setValue(iface.progress)
+ iface.do_write(source, target)
+ progress = iface.progress
+ while progress < 100 :
+ progress = iface.progress
+ self.progress.setValue(progress)
time.sleep(1)
success, message = iface.end()
if success:
self.logger(_('Image {source} successfully written to {target}').format( source=source.split('/')[-1], target=target))
self.logger(_('Bytes written: ')+str(b))
- self.check_write(target, b)
+ self.progress.setLabel(_('Checking ')+target.split('/')[-1])
+ self.progress.setValue(0)
+ iface.check_write(target, source)
+ progress = iface.progress
+ while progress < 100 :
+ progress = iface.progress
+ self.progress.setValue(progress)
+ time.sleep(1)
+ success, message = iface.end()
+ self.progress.setEnabled()
+ self.progress.setValue(100)
+ self.logger(message)
self.success()
else:
self.emergency(message)
@@ -308,41 +319,6 @@ class IsoDumper(object):
else:
self.restore()
- def check_write(self, target, b):
- import hashlib
- self.progress.setEnabled()
- self.progress.setLabel(_('Checking ')+target.split('/')[-1])
- self.progress.setValue(0)
- steps=list(range(0, b+1, int(b/100)))
- steps.append(b)
- indice=0
- checked=0
- sha1func=hashlib.sha1()
- md5func=hashlib.md5()
- ncuts=int(b/1024)
- try:
- with open(target, 'rb') as f:
- for x in range(0,ncuts):
- block = f.read(1024)
- sha1func.update(block)
- md5func.update(block)
- if checked > steps[indice]:
- self.progress.setValue(indice)
- self.dialog.pollEvent()
- indice +=1
- checked+=1024
- block = f.read(b-ncuts*1024)
- sha1func.update(block)
- md5func.update(block)
- sha1sumcalc=sha1func.hexdigest()
- md5sumcalc=md5func.hexdigest()
- self.logger(_('SHA1 sum: ')+sha1sumcalc)
- self.logger(_('MD5 sum: ')+md5sumcalc)
- f.close()
- except:
- pass
- self.progress.setValue(100)
-
def success(self):
self.operation=False
self.final_unsensitive()