diff options
author | Papoteur <papoteur@mageialinux-online.org> | 2015-08-05 20:20:15 +0200 |
---|---|---|
committer | Papoteur <papoteur@mageialinux-online.org> | 2015-08-05 20:20:15 +0200 |
commit | b2acd0fe448e0e4fffba34a70ad79958c62c3f28 (patch) | |
tree | 42049441692e9c8ba9044c6a6dee0d7d961c6ab9 /lib/isodumper.py | |
parent | fb7283a9d8e8fa0c2fb6e3dfc77d157a0e9d859f (diff) | |
download | isodumper-b2acd0fe448e0e4fffba34a70ad79958c62c3f28.tar isodumper-b2acd0fe448e0e4fffba34a70ad79958c62c3f28.tar.gz isodumper-b2acd0fe448e0e4fffba34a70ad79958c62c3f28.tar.bz2 isodumper-b2acd0fe448e0e4fffba34a70ad79958c62c3f28.tar.xz isodumper-b2acd0fe448e0e4fffba34a70ad79958c62c3f28.zip |
Update to suppress specific UEFI writing
Diffstat (limited to 'lib/isodumper.py')
-rw-r--r-- | lib/isodumper.py | 153 |
1 files changed, 15 insertions, 138 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py index ee1c8bc..953ff25 100644 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -190,17 +190,6 @@ class UDisks2(object): drive.Eject({'auth.no_user_interaction':True}, dbus_interface=self.DRIVE) -def countFiles(directory): - files = [] - if os.path.isdir(directory): - for path, dirs, filenames in os.walk(directory): - files.extend(filenames) - return len(files) - -def makedirs(dest): - if not os.path.exists(dest): - os.makedirs(dest) - class Info(object): def __init__(self,title,richtext,text): self.title=title @@ -370,70 +359,13 @@ class IsoDumper(object): self.writebt.setDisabled() self.do_umount(target) # Writing step - # Iso dump or Uefi preparation - if self.uefi_check.isChecked(): - #uefi mode : formats FAT32, names MGALIVE, copies the ISO - target = self.dev.split('(')[1].split(')')[0] - dev_name="MGALIVE" - rc=self.raw_format(target, 'fat32', dev_name) - if rc == 5: - message = _("An error occurred while creating a partition.") - self.logger(message) - self.emergency(message) - elif rc == 127: - message = _('Authentication error.') - self.logger(message) - self.emergency(message) - elif rc == 0: - message = _('The device was formatted successfully.') - self.logger(message) - seen=False - part=target+'1' - while(not seen): - try: - self.u.device(part) - seen=True - except: - seen=False - time.sleep(.5) - try: - dest=self.u.mount(part) - except: - message = _("Error mounting the partition %s")%part - self.logger(message) - self.emergency(message) - return - if dest!="": - self.logger(_("Mounted in: ")) - self.returncode=0 - self.files_write(source, dest) - self.operation=False - if self.returncode==0: - self.success() - else: - message = _("Error copying files") - self.logger(message) - self.emergency(message) - try: - self.u.unmount(part) - except: - pass - else: - self.operation=False - message = _("Error mounting the partition %s")%part - self.logger(message) - self.emergency(message) - else: - message = _('An error occurred.') - self.emergency(message) - else: - #Dump mode - self.returncode=0 - b=os.path.getsize(source) - self.raw_write(source, target, b) - self.check_write(target, b) - if self.returncode == 0: - self.success() + #Dump mode + self.returncode=0 + b=os.path.getsize(source) + self.raw_write(source, target, b) + self.check_write(target, b) + if self.returncode == 0: + self.success() else: self.restore() def do_umount(self, target): @@ -574,59 +506,6 @@ class IsoDumper(object): pass self.progress.setValue(100) - def files_write(self, source, dest): - self.operation=True - temp_dir='/mnt/MGALIVE' - makedirs(temp_dir) - self.process=Popen(['mount', '-o', 'loop',source,temp_dir ], shell=False, stdout=PIPE) - working=True - while working: - time.sleep(0.5) - self.process.poll() - rc=self.process.returncode - if rc is None: - working=True - else: - self.process = None - working=False - total_files=countFiles(temp_dir) - cumuled_size=0 - if total_files > 0: - self.logger(_('ISO image mounted in ')+temp_dir) - self.progress.setEnabled() - self.progress.setLabel(_('Writing ')+source.split('/')[-1]+_(' to ')+dest.encode()) - self.logger(_('Executing copy from ')+source+_(' to ')+dest.encode()) - self.logger(_("%s file(s) to copy."%total_files)) - for path, dirs, filenames in os.walk(temp_dir): - for directory in dirs: - destDir = path.replace(temp_dir,dest) - makedirs(os.path.join(destDir, directory)) - for sfile in filenames: - srcFile = os.path.join(path, sfile) - destFile = os.path.join(path.replace(temp_dir, dest), sfile) - 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) - self.progress.setValue(int(cumuled_size*100/total_files)) - except: - self.returncode=1 - return - 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.encode()) - else: - self.returncode=1 - def success(self): self.operation=False self.final_unsensitive() @@ -699,20 +578,19 @@ class IsoDumper(object): # self.chooser.set_tooltip_text(self.img_name) def help_dialog(self): - print("Help 2") info = Info(_("IsoDumper"),0,_("Mageia IsoDumper\n\ ----------------\n\ -This GUI program is primarily for safely writing a bootable ISO image to a USB flash drive, an operation devious & potentially hazardous when done by hand. As a bonus, it can also back up the entire previous contents of the flash drive onto the hard disc, and restore the flash drive to its previous state subsequently. It gives also a feature for formatting the USB device.\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\ -IsoDumper can be launched either from the menus, or a user or root console with the command 'isodumper'. For normal users, the root password is solicited; this is necessary for the program's operation. The flash drive can be inserted beforehand or once the program is started. In the latter case, a dialogue will say that there is no flash drive inserted, and allow a 'retry' to find it once it is. (You may have to close any automatically opened File Manager window).\n\ +IsoDumper can be launched either from the menus, or a user or root console with the command 'isodumper'.\nFor normal users, the root password is solicited; this is necessary for the program's operation. \nThe flash drive can be inserted beforehand or once the program is started. In the latter case, a dialogue will say \nthat there is no flash drive inserted, and allow a 'retry' to find it once it is. \n(You may have to close any automatically opened File Manager window).\n\ \n\ The fields of the main window are as follows:\n\ - Device to work on: the device of the USB flash drive, a drop-down list to choose from.\n\ - Write Image: to choose the source ISO image *.iso (or flash drive backup file *.img) to write out.\n\ -- Write to device: This button launches the operation - with a prior warning dialogue. The operation is shown in the progress bar beneath.\n\ -- Backup in: define the name and placement of the backup image file. The current flash drive will be backed up to a disc file. Note that the entire flash drive is preserved, regardless of its actual contents; ensure that you have the necessary free disc space (the same size as the USB device). This backup file can be used later to restore the flash drive by selecting it as the source *.img file to write out.\n\ +- Write to device: This button launches the operation - with a prior warning dialogue. \nThe operation is shown in the progress bar beneath.\n\ +- Backup in: define the name and placement of the backup image file. The current flash \ndrive will be backed up to a disc file. Note that the entire flash drive is preserved, regardless of its actual contents;\n ensure that you have the necessary free disc space (the same size as the USB device). \nThis backup file can be used later to restore the flash drive by selecting it as the source *.img file to write out.\n\ - Backup the device: launch the backup operation.\n\ -- Format the device: create an unique partition on the entire volume in the specified format in FAT, NTFS or ext. You can specify a volume name and the format in a new dialog box.\n")) +- Format the device: create an unique partition on the entire volume in the specified format in FAT, \nNTFS or ext. You can specify a volume name and the format in a new dialog box.\n")) if self.ask_OK(info) : return @@ -751,7 +629,7 @@ The fields of the main window are as follows:\n\ # +---+-----------------+ # | devicelist | # +---+-----+------+----+ - # + L | ima | uefi_check | writebt | + # + L | ima | writebt | # +---+-----+------+----+ # + L | backup_select | backupbt | # +---+-----+------+----+ @@ -778,7 +656,6 @@ The fields of the main window are as follows:\n\ # add file picker self.ima=self.atelier.createPushButton(self.writebox,"Choose an image") self.ima.setStretchable(0,True) - self.uefi_check=self.atelier.createCheckBox(self.writebox,_("For UEFI")) self.atelier.createHStretch(self.writebox) self.writebt = self.atelier.createPushButton(self.writebox, _("&Write" )) #self.writebt.setStretchable(0,True) @@ -786,7 +663,7 @@ The fields of the main window are as follows:\n\ self.backupbox = self.atelier.createHBox(self.box) #self.backupbox.setWeight(1,10) self.atelier.createLabel(self.backupbox,_("Backup to:")) - self.backup_select=self.atelier.createPushButton(self.backupbox,"Choose an image") + self.backup_select=self.atelier.createPushButton(self.backupbox,_("Choose an image")) self.backup_select.setStretchable(0,True) self.atelier.createHStretch(self.backupbox) self.backupbt = self.atelier.createPushButton(self.backupbox, _("&Backup" )) @@ -890,7 +767,7 @@ The fields of the main window are as follows:\n\ dlg.setTitle(info.title) dlg.setText(info.text, info.richtext) dlg.setButtonLabel("OK", yui.YMGAMessageBox.B_ONE) - dlg.setMinSize(50, 5); + dlg.setMinSize(100, 10); return dlg.show() == yui.YMGAMessageBox.B_ONE def ask_YesOrNo(self, info): |