diff options
-rw-r--r-- | lib/isodumper.py | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py index aa5c581..6dd3647 100644 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -131,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 list(objects.keys())] + [re_drive.match(path) for path in objects.keys()] if m] blocks = [m.groupdict() for m in - [re_block.match(path) for path in list(objects.keys())] + [re_block.match(path) for path in objects.keys()] if m] list=[] @@ -157,7 +157,7 @@ class UDisks2(object): def unmount(self, device_node_path): d = self.device(device_node_path) - d.Unmount({'force':True, 'auth.no_user_interaction':True}, + d.Unmount({'force':False, 'auth.no_user_interaction':True}, dbus_interface=self.FILESYSTEM) def drive_for_device(self, device): @@ -234,7 +234,7 @@ class IsoDumper(object): def do_format(self,format_type,name) : target = self.dev.split('(')[1].split(')')[0] - info = Info(_("Formatting confirmation"),1,self.warning) + info = Info(_("Formatting confirmation"),True,self.warning) if self.ask_YesOrNo(info): rc=self.raw_format(target, format_type, name) self.operation=False @@ -286,7 +286,7 @@ class IsoDumper(object): def backup_go(self): dest = self.backup_img_name if os.path.exists(dest): - info = Info(_("Backup confirmation"),1,_("Do you want to overwrite the file?")) + info = Info(_("Backup confirmation"),True,_("Do you want to overwrite the file?")) if not(self.ask_YesOrNo(info)): self.returncode = 1 return True @@ -325,10 +325,10 @@ class IsoDumper(object): self.logger(message) self.emergency(message) else: - info = Info(_("Writing confirmation"),1,self.warning) + info = Info(_("Writing confirmation"),True,self.warning) if self.ask_YesOrNo(info): if self.deviceSize> 1024*1024*1024*32 : - info = Info(_("Warning"),2,_('The device is bigger than 32 Gbytes.\ + info = Info(_("Warning"),True,_('The device is bigger than 32 Gbytes.\ Are you sure you want use it?')) if self.ask_YesOrNo(info): pass @@ -355,7 +355,8 @@ class IsoDumper(object): for mount in mounts: self.logger(_('Trying to unmount ')+mount[0]+'...') try: - retcode = call('umount '+mount[0], shell=True) + #retcode = call('umount '+mount[0], shell=True) + retcode = self.u.unmount(mount[0]) if retcode < 0: message = _('Error, umount ')+mount[0]+_(' was terminated by signal ')+str(retcode) self.logger(message) @@ -464,32 +465,32 @@ class IsoDumper(object): md5func=hashlib.md5() ncuts=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 + 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() - info = Info(_("Success"),1,_("The operation was successfully performed.\n\ + info = Info(_("Success"),True,_("The operation was successfully performed.\n\ You are free to unplug it now, a log isodumper.log\n\ of the operation will be saved in your homedir/.isodumper/ when\n\ you close the application.")) @@ -501,7 +502,7 @@ class IsoDumper(object): if self.operation==False: # no writing , backup nor format running self.close() else: # writing , backup or format running - info = Info(_("Warning"),1,_("Writing is in progress. Exiting during writing \n\ + info = Info(_("Warning"),True,_("Writing is in progress. Exiting during writing \n\ will occur that the device or the backup will be unusable.\n\ Are you sure you want to quit during writing?")) if self.ask_YesOrNo(info) : @@ -513,7 +514,7 @@ class IsoDumper(object): self.operation=False self.returncode=1 self.final_unsensitive() - info = Info(_("Error"),1,message) + info = Info(_("Error"),True,message) self.ask_OK(info) def final_unsensitive(self): @@ -558,7 +559,7 @@ class IsoDumper(object): # self.chooser.set_tooltip_text(self.img_name) def help_dialog(self): - info = Info(_("IsoDumper"),0,_("Mageia IsoDumper\n\ + info = Info(_("IsoDumper"),True,_("Mageia IsoDumper\n\ ----------------\n\ This GUI program is primarily for safely writing a bootable ISO image to a USB flash drive, \nan operation devious & potentially hazardous when done by hand. As a bonus, it can also back up the entire previous\ncontents of the flash drive onto the hard disc, and restore the flash drive to its previous state subsequently.\n It gives also a feature for formatting the USB device.\n\ \n\ @@ -577,7 +578,7 @@ The fields of the main window are as follows:\n\ def __init__(self,user): APP="isodumper" DIR="/usr/share/locale" - self.RELEASE="v0.40" + self.RELEASE="v0.50" gettext.bindtextdomain(APP, DIR) gettext.textdomain(APP) @@ -598,11 +599,10 @@ The fields of the main window are as follows:\n\ """ Init/Constructor for the 'widgets' """ - yui.YUI.app().setApplicationTitle("ManaDumper") + yui.YUI.app().setApplicationTitle(_("ManaDumper")+" "+self.RELEASE) yui.YUI.app().setApplicationIcon("/usr/share/icons/isodumper.png") self.atelier = yui.YUI.widgetFactory() self.dialog = self.atelier.createMainDialog() - #self.dialog.setTitle("ManaDumper") # create the main gui # +---+-----------------+ # + banner + @@ -773,9 +773,9 @@ The fields of the main window are as follows:\n\ mgafactory = yui.YMGAWidgetFactory.getYMGAWidgetFactory(yui.YExternalWidgets.externalWidgetFactory("mga")) dlg = mgafactory.createDialogBox(yui.YMGAMessageBox.B_TWO) dlg.setTitle("IsoDumper") - dlg.setText("Warning\nNo target devices were found.\nYou need to plug in a USB Key to which the image can be written.") - dlg.setButtonLabel("Refresh", yui.YMGAMessageBox.B_ONE) - dlg.setButtonLabel("Cancel", yui.YMGAMessageBox.B_TWO) + dlg.setText(_("Warning\nNo target devices were found.\nYou need to plug in a USB Key to which the image can be written.")) + dlg.setButtonLabel(_("Refresh"), yui.YMGAMessageBox.B_ONE) + dlg.setButtonLabel(_("Cancel"), yui.YMGAMessageBox.B_TWO) dlg.setMinSize(70, 8); return dlg.show() == yui.YMGAMessageBox.B_ONE |