aboutsummaryrefslogtreecommitdiffstats
path: root/lib/isodumper.py
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2018-03-11 13:52:55 +0100
committerPapoteur <papoteur@mageia.org>2018-03-16 11:17:42 +0100
commitcf47ed2aa96097466370456eeb66709370707cb8 (patch)
tree9d235c57e37ce412cea303e528cc598eda1ec0f0 /lib/isodumper.py
parent0481b62e786c6b615a4ad3ed9ddd648a18e7805c (diff)
downloadisodumper-cf47ed2aa96097466370456eeb66709370707cb8.tar
isodumper-cf47ed2aa96097466370456eeb66709370707cb8.tar.gz
isodumper-cf47ed2aa96097466370456eeb66709370707cb8.tar.bz2
isodumper-cf47ed2aa96097466370456eeb66709370707cb8.tar.xz
isodumper-cf47ed2aa96097466370456eeb66709370707cb8.zip
move check_write on DBus
Root right are needed to read /dev/sdX Cleaning messages
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()