aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/isodumper.py68
1 files changed, 32 insertions, 36 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index dbf44b8..85487a0 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -393,21 +393,13 @@ class IsoDumper(basedialog.BaseDialog):
rc = self.raw_format(target, format_type, name)
self.operation = False
if rc == 0:
- message = _('The device was formatted successfully.')
- self.logger(message)
- self.success()
+ return True, _('The device was formatted successfully.')
elif rc == 5:
- message = _("An error occurred while creating a partition.")
- self.logger(message)
- self.emergency(message)
+ return False, _("An error occurred while creating a partition.")
elif rc == 127:
- message = _('Authentication error.')
- self.logger(message)
- self.emergency(message)
+ return False, _('Authentication error.')
else:
- message = _('An error {} occurred.'.format(rc))
- self.emergency(message)
- self.initial_state()
+ return False, _('An error {} occurred.'.format(rc))
def initial_state(self):
self.update_list()
@@ -466,7 +458,7 @@ class IsoDumper(basedialog.BaseDialog):
self.init_iface()
self.wip_unsensitive()
self.progress.setEnabled()
- self.progress.setLabel("Backup")
+ self.progress.setLabel(_("Backup"))
dest = self.backup_img_name
if os.path.exists(dest):
info = Info(_("Backup confirmation"), True, _("Do you want to overwrite the file?"))
@@ -482,7 +474,7 @@ class IsoDumper(basedialog.BaseDialog):
logging.warning(message)
self.emergency(message)
self.initial_state()
- return False
+ return False, message
else:
self.operation = True
self.returncode = 0
@@ -498,23 +490,12 @@ class IsoDumper(basedialog.BaseDialog):
self.dialog.pollEvent()
time.sleep(.2)
success, message = self.iface.end()
- if success:
- # I18N: don't translate source nor target
- message = _('{source} successfully written to {target}').format(source=source.split('/')[-1], target=dest)
- self.logger(message)
- logging.info(message)
- self.progress.setEnabled()
- self.progress.setValue(100)
- self.dialog.pollEvent()
- self.logger(message)
- logging.info(message)
- self.success()
- self.initial_state()
- else:
+ if not success:
self.emergency(message)
self.initial_state()
- return False
- return True
+ return False, message
+ # I18N: don't translate source nor target
+ return True, _('{source} successfully written to {target}').format(source=source.split('/')[-1], target=dest)
def do_write(self):
self.init_iface()
@@ -902,11 +883,8 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
# Connect events
self.eventManager.addWidgetEvent(self.quitbt, self.confirm_close)
self.eventManager.addWidgetEvent(self.ima, self.ask_image)
- #self.eventManager.addWidgetEvent(self.writebt, self.do_write)
self.eventManager.addWidgetEvent(self.cryptcb, self.check_encryt)
- #self.eventManager.addWidgetEvent(self.backupbt, self.backup_go)
self.eventManager.addWidgetEvent(self.backup_select, self.backup_choosed)
- #self.eventManager.addWidgetEvent(self.formatbt, self.do_format)
self.eventManager.addWidgetEvent(self.backup_cbox, self.select_backup)
self.eventManager.addWidgetEvent(self.write_cbox, self.select_write)
self.eventManager.addWidgetEvent(self.partition_cbox, self.select_partition)
@@ -1051,14 +1029,17 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
self.interface_active_state()
def start(self):
+ backup_success = False
if self.backup_cbox.isChecked():
# check that a name is set
if self.backup_is_selected:
- if self.backup_go():
- self.backup_is_selected = False
- else:
+ backup_success, message = self.backup_go()
+ if not backup_success:
# something went wrong, we stop
+ self.initial_state()
return
+ self.logger(message)
+ logging.info(message)
else:
info = Info(_("Error"), True, _("No image for backup is selected."))
self.ask_OK(info)
@@ -1073,7 +1054,22 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog
return
if self.partition_cbox.isChecked():
# Create a partition without writing image, will use all the device space.
- self.do_format()
+ format_success, message = self.do_format()
+ if format_success:
+ self.logger(message)
+ logging.info(message)
+ self.success()
+ else:
+ self.logger(message)
+ logging.info(message)
+ self.emergency(message)
+ elif backup_success:
+ # success message when no other operation after backup
+ self.progress.setEnabled()
+ self.progress.setValue(100)
+ self.dialog.pollEvent()
+ self.success()
+ self.initial_state()
def ask_format(self):