From 5e9f15ab850a406663634ba899d9abf1d144db66 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Sun, 8 Mar 2015 08:16:51 +0100 Subject: Change writing mode for UEFI --- lib/isodumper.py | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/isodumper.py b/lib/isodumper.py index ba16a2b..590db25 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -138,7 +138,7 @@ class UDisks2(object): try: d = self.device(device_node_path) mount_options = ['rw', 'noexec', 'nosuid', - 'nodev', 'uid=%d'%os.geteuid(), 'gid=%d'%os.getegid()] + 'nodev','uid=%d'%os.geteuid(), 'gid=%d'%os.getegid()] r=d.Mount( { 'auth.no_user_interaction':True, @@ -184,7 +184,7 @@ class IsoDumper: def __init__(self,user): APP="isodumper" DIR="/usr/share/locale" - RELEASE="v0.40" + RELEASE="v0.41" gettext.bindtextdomain(APP, DIR) gettext.textdomain(APP) @@ -462,7 +462,7 @@ class IsoDumper: dialog = self.wTree.get_widget("confirm_dialog") # if self.backup.get_active() : # backup_dest=self.backup_select.get_label() - self.logger(_('Image: ')+source) +# self.logger(_('Image: ')+source) self.logger(_('Target Device: ')+self.dev) b = os.path.getsize(source) if b > (self.deviceSize): @@ -522,7 +522,7 @@ class IsoDumper: if dest!="": self.logger(_("Mounted in: ")+dest) self.returncode=0 - task = self.files_write(source, dest) + task = self.files_write(source, dest, b) gobject.idle_add(task.next) self.operation=False while gtk.events_pending(): @@ -642,6 +642,8 @@ class IsoDumper: mark = self.log.create_mark("end", self.log.get_end_iter(), False) self.logview.scroll_to_mark(mark, 0.05, True, 0.0, 1.0) progress.set_fraction(float(indice)/100) + while gtk.events_pending(): + gtk.main_iteration(True) indice +=1 try: os.fsync(ofc) @@ -702,9 +704,9 @@ class IsoDumper: progress.set_fraction(1.0) yield False - def files_write(self, source, dest): - import shutil + def files_write(self, source, dest, size): self.operation=True + self.logger(time.ctime(time.time())) temp_dir='/mnt/MGALIVE' makedirs(temp_dir) self.process=Popen(['mount', '-o', 'loop',source,temp_dir ], shell=False, stdout=PIPE) @@ -727,8 +729,8 @@ class IsoDumper: gtk.main_iteration(True) total_files=countFiles(temp_dir) self.logger(_("%s file(s) to copy."%total_files)) + cumuled_size=0 if total_files > 0: - numCopied = 0 for path, dirs, filenames in os.walk(temp_dir): for directory in dirs: destDir = path.replace(temp_dir,dest) @@ -736,12 +738,33 @@ class IsoDumper: for sfile in filenames: srcFile = os.path.join(path, sfile) destFile = os.path.join(path.replace(temp_dir, dest), sfile) - shutil.copy2(srcFile, destFile) - numCopied += 1 - progress.set_fraction(float(numCopied)/total_files) + try: + with open(srcFile, 'rb') as fsrc: + with open(destFile, 'wb') as fdst: + while 1: + buf = fsrc.read(256*1024) + if not buf: + os.fsync(fdst) + break + fdst.write(buf) + cumuled_size += len(buf) + progress.set_fraction(min(float(cumuled_size)/size,1)) + print float(cumuled_size)/size + while gtk.events_pending(): + gtk.main_iteration(True) + except: + self.returncode=1 + return + while gtk.events_pending(): + gtk.main_iteration(True) yield True self.process = Popen(['umount', temp_dir ], shell=False, stdout=PIPE) + while True : + self.process.poll() + if self.process.returncode != None: + break self.logger(_('Image ')+source.split('/')[-1]+_(' successfully written to ')+dest) + self.logger(time.ctime(time.time())) else: self.returncode=1 -- cgit v1.2.1