2
0
mirror of https://github.com/mbusb/multibootusb synced 2024-11-18 15:25:46 +00:00

code cleanup

This commit is contained in:
Alin Trăistaru 2017-05-03 13:26:10 +03:00
parent 7695cc43c2
commit 92a580d0a4
9 changed files with 64 additions and 90 deletions

View File

@ -80,7 +80,7 @@ def list_iso(iso_link, suppress_out=True):
if '.....' in line: if '.....' in line:
if gen.has_digit(line[2]) or gen.has_digit(line[4]): if gen.has_digit(line[2]) or gen.has_digit(line[4]):
if len(line) > 6: if len(line) > 6:
f_path = " ".join(line[5:len(line)]) f_path = " ".join(line[5:])
file_list.append(f_path) file_list.append(f_path)
else: else:
f_path = line[-1] f_path = line[-1]
@ -115,10 +115,7 @@ def test_iso(iso_link, suppress_out=True):
rc = subprocess.call(_cmd, shell=True) rc = subprocess.call(_cmd, shell=True)
if rc == 0 or rc == 1: return bool(rc in [0, 1])
return True
else:
return False
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -86,7 +86,10 @@ def runAsAdmin(cmdLine=None, wait=True):
# raise RuntimeError, "This function is only implemented on Windows." # raise RuntimeError, "This function is only implemented on Windows."
if platform.system() == "Windows": if platform.system() == "Windows":
import win32api, win32con, win32event, win32process import win32api
import win32con
import win32event
import win32process
from win32com.shell.shell import ShellExecuteEx from win32com.shell.shell import ShellExecuteEx
from win32com.shell import shellcon from win32com.shell import shellcon

View File

@ -112,10 +112,7 @@ def is_quoted(text):
:param text: Any word or sentence with or without quote. :param text: Any word or sentence with or without quote.
:return: True if text is quoted else False. :return: True if text is quoted else False.
""" """
if text.startswith("\"") and text.endswith("\""): return bool(text.startswith("\"") and text.endswith("\""))
return True
else:
return False
def has_digit(word): def has_digit(word):
@ -266,10 +263,8 @@ def size_not_enough(iso_link, usb_disk):
isoSize = iso_size(iso_link) isoSize = iso_size(iso_link)
usb_details = details(usb_disk) usb_details = details(usb_disk)
usb_size = usb_details['size_free'] usb_size = usb_details['size_free']
if isoSize > usb_size:
return True return bool(isoSize > usb_size)
else:
return False
def mbusb_version(): def mbusb_version():
@ -339,12 +334,12 @@ def prepare_mbusb_host_dir():
log("Removing junk files...") log("Removing junk files...")
for files in os.listdir(os.path.join(home, "iso_cfg_ext_dir")): for files in os.listdir(os.path.join(home, "iso_cfg_ext_dir")):
if os.path.isdir(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files))): if os.path.isdir(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files))):
log (os.path.join(os.path.join(home, "iso_cfg_ext_dir", files))) log(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files)))
os.chmod(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files)), 0o777) os.chmod(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files)), 0o777)
shutil.rmtree(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files))) shutil.rmtree(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files)))
else: else:
try: try:
log (os.path.join(os.path.join(home, "iso_cfg_ext_dir", files))) log(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files)))
os.chmod(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files)), 0o777) os.chmod(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files)), 0o777)
os.unlink(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files))) os.unlink(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files)))
os.remove(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files))) os.remove(os.path.join(os.path.join(home, "iso_cfg_ext_dir", files)))

View File

@ -144,7 +144,7 @@ def get_grub_cfg(iso_link, efi=True):
def grub_custom_menu(mbus_grub_cfg_path, distro): def grub_custom_menu(mbus_grub_cfg_path, distro):
iso_size_mb = bytes2human(iso.iso_size(config.image_path)) iso_size_mb = bytes2human(iso.iso_size(config.image_path))
gen.log('size of the ISO is ' + str(iso_size_mb)) gen.log('size of the ISO is ' + str(iso_size_mb))
if distro == 'sgrubd2' or distro == 'raw_iso': if distro in ['sgrubd2', 'raw_iso']:
grub_raw_iso(mbus_grub_cfg_path) grub_raw_iso(mbus_grub_cfg_path)
''' '''

View File

@ -152,15 +152,15 @@ class ISO9660:
BLOCK_SIZE = priVol.blockSize BLOCK_SIZE = priVol.blockSize
# Check RRIP # Check RRIP
#gen.log ("loc extent(%d)"%(dirRec.locExtent)) #gen.log("loc extent(%d)"%(dirRec.locExtent))
self.priVol = priVol # readDirItems will use self.priVol self.priVol = priVol # readDirItems will use self.priVol
root_dir = self.readDirItems(dirRec.locExtent, priVol.rootTotal)[0] root_dir = self.readDirItems(dirRec.locExtent, priVol.rootTotal)[0]
rripNode = self.__rripLoop__(root_dir.suspBuf, root_dir.lenDr-root_dir.sysUseStar) rripNode = self.__rripLoop__(root_dir.suspBuf, root_dir.lenDr-root_dir.sysUseStar)
if rripNode.offset != -1: if rripNode.offset != -1:
self.rripOffset = rripNode.offset self.rripOffset = rripNode.offset
#gen.log ("RRIP: rrip_offset %d"%(self.rripOffset)) #gen.log("RRIP: rrip_offset %d"%(self.rripOffset))
else: else:
gen.log ("This ISO doesn't support RRIP") gen.log("This ISO doesn't support RRIP")
self.rootDir = root_dir self.rootDir = root_dir
# Rrip extension # Rrip extension
@ -168,7 +168,7 @@ class ISO9660:
if self.rripOffset > 0: if self.rripOffset > 0:
entry_buf = desc_buf[self.rripOffset:] entry_buf = desc_buf[self.rripOffset:]
gen.log ("__rripLoop__ offset:%d"%(self.rripOffset)) gen.log("__rripLoop__ offset:%d"%(self.rripOffset))
else: else:
entry_buf = desc_buf entry_buf = desc_buf
@ -181,7 +181,7 @@ class ISO9660:
len_entry = 0 len_entry = 0
while True: while True:
#gen.log (("\n%d, %d\n")%(len_buf, head)) #gen.log(("\n%d, %d\n")%(len_buf, head))
head += len_entry head += len_entry
if len_buf - head < 4: # less than one entry if len_buf - head < 4: # less than one entry
break break
@ -322,7 +322,7 @@ class ISO9660:
else: else:
return item return item
else: else:
gen.log ("can't find " + dircomps[i_dircomp]) gen.log("can't find " + dircomps[i_dircomp])
return None return None
def readDirrecord(self, desc_buf): def readDirrecord(self, desc_buf):
@ -628,7 +628,7 @@ class ISO9660:
lastfile_end = BLOCK_SIZE * dr2.locExtent + dr2.lenData lastfile_end = BLOCK_SIZE * dr2.locExtent + dr2.lenData
self.isoFile.seek(0, os.SEEK_END) self.isoFile.seek(0, os.SEEK_END)
iso_end = self.isoFile.tell() iso_end = self.isoFile.tell()
#gen.log ("%d-->%d")%(lastfile_end, iso_end) #gen.log("%d-->%d")%(lastfile_end, iso_end)
if iso_end >= lastfile_end: if iso_end >= lastfile_end:
return True return True
else: else:

View File

@ -27,27 +27,6 @@ class Qemu(QtWidgets.QMainWindow, Ui_MainWindow):
QtWidgets.QMainWindow.__init__(self) QtWidgets.QMainWindow.__init__(self)
self.ui = Ui_MainWindow() self.ui = Ui_MainWindow()
self.ui.setupUi(self) self.ui.setupUi(self)
# def on_Qemu_Browse_iso_Click(self):
# """
# Browse and choose an ISO.
# :return:
# """
# self.ui.lineEdit_2.clear()
#
# qemu = self.check_qemu_exist()
#
# if not qemu is None:
# qemu_iso_link = QtWidgets.QFileDialog.getOpenFileName(self, 'Select an iso...', "", "ISO Files (*.iso)")[0]
# else:
# log("QEMU does not exist.\nPlease install qemu package to avail this feature.")
# QtWidgets.QMessageBox.information(self, 'No QEMU...', 'Please install qemu package to avail this feature.')
# qemu_iso_link = None
#
# if not qemu_iso_link is None:
# self.ui.lineEdit_2.insert(qemu_iso_link)
# else:
# log ("File not selected.")
def on_Qemu_Boot_iso_Click(self): def on_Qemu_Boot_iso_Click(self):
""" """

View File

@ -24,18 +24,18 @@ mbr_bin = resource_path(os.path.join("data", "tools", "mbr.bin"))
def set_boot_flag(usb_disk): def set_boot_flag(usb_disk):
if platform.system() == "Linux": if platform.system() == "Linux":
log ("\nChecking boot flag on " + usb_disk[:-1], '\n') log("\nChecking boot flag on " + usb_disk[:-1], '\n')
cmd_out = subprocess.check_output("parted -m -s " + usb_disk[:-1] + " print", shell=True) cmd_out = subprocess.check_output("parted -m -s " + usb_disk[:-1] + " print", shell=True)
if b'boot' in cmd_out: if b'boot' in cmd_out:
log ("\nDisk " + usb_disk[:-1] + " already has boot flag.\n") log("\nDisk " + usb_disk[:-1] + " already has boot flag.\n")
return True return True
else: else:
log ("\nExecuting ==> parted " + usb_disk[:-1] + " set 1 boot on", '\n') log("\nExecuting ==> parted " + usb_disk[:-1] + " set 1 boot on", '\n')
if subprocess.call("parted " + usb_disk[:-1] + " set 1 boot on", shell=True) == 0: if subprocess.call("parted " + usb_disk[:-1] + " set 1 boot on", shell=True) == 0:
log ("\nBoot flag set to bootable " + usb_disk[:-1], '\n') log("\nBoot flag set to bootable " + usb_disk[:-1], '\n')
return True return True
else: else:
log ("\nUnable to set boot flag on " + usb_disk[:-1], '\n') log("\nUnable to set boot flag on " + usb_disk[:-1], '\n')
return False return False
@ -50,18 +50,18 @@ def syslinux_default(usb_disk, version=4):
usb_fs = usb_details['file_system'] usb_fs = usb_details['file_system']
usb_mount = usb_details['mount_point'] usb_mount = usb_details['mount_point']
mbr_install_cmd = 'dd bs=440 count=1 conv=notrunc if=' + mbr_bin + ' of=' + usb_disk[:-1] mbr_install_cmd = 'dd bs=440 count=1 conv=notrunc if=' + mbr_bin + ' of=' + usb_disk[:-1]
# log (usb_fs) # log(usb_fs)
if usb_fs in extlinux_fs: if usb_fs in extlinux_fs:
extlinu_cmd = extlinux_path + ' --install ' + os.path.join(usb_mount, 'multibootusb') extlinu_cmd = extlinux_path + ' --install ' + os.path.join(usb_mount, 'multibootusb')
if os.access(extlinux_path, os.X_OK) is False: if os.access(extlinux_path, os.X_OK) is False:
subprocess.call('chmod +x ' + extlinux_path, shell=True) subprocess.call('chmod +x ' + extlinux_path, shell=True)
log ("\nExecuting ==> " + extlinu_cmd) log("\nExecuting ==> " + extlinu_cmd)
config.status_text = 'Installing default extlinux version 4...' config.status_text = 'Installing default extlinux version 4...'
if subprocess.call(extlinu_cmd, shell=True) == 0: if subprocess.call(extlinu_cmd, shell=True) == 0:
log ("\nDefault Extlinux install is success...\n") log("\nDefault Extlinux install is success...\n")
config.status_text = 'Default extlinux install is success...' config.status_text = 'Default extlinux install is success...'
config.status_text = 'Installing mbr...' config.status_text = 'Installing mbr...'
log ('\nExecuting ==> ' + mbr_install_cmd) log('\nExecuting ==> ' + mbr_install_cmd)
if subprocess.call(mbr_install_cmd, shell=True) == 0: if subprocess.call(mbr_install_cmd, shell=True) == 0:
config.status_text = 'mbr install is successful...' config.status_text = 'mbr install is successful...'
log("\nmbr install is success...\n") log("\nmbr install is success...\n")
@ -74,31 +74,31 @@ def syslinux_default(usb_disk, version=4):
syslinux_cmd = syslinux_path + ' -i -d multibootusb ' + usb_disk syslinux_cmd = syslinux_path + ' -i -d multibootusb ' + usb_disk
if os.access(syslinux_path, os.X_OK) is False: if os.access(syslinux_path, os.X_OK) is False:
subprocess.call('chmod +x ' + syslinux_path, shell=True) subprocess.call('chmod +x ' + syslinux_path, shell=True)
log ("\nExecuting ==> " + syslinux_cmd + "\n") log("\nExecuting ==> " + syslinux_cmd + "\n")
config.status_text = 'Installing default syslinux version 4...' config.status_text = 'Installing default syslinux version 4...'
if subprocess.call(syslinux_cmd, shell=True) == 0: if subprocess.call(syslinux_cmd, shell=True) == 0:
log ("\nDefault syslinux install is success...\n") log("\nDefault syslinux install is success...\n")
config.status_text = 'Default syslinux successfully installed...' config.status_text = 'Default syslinux successfully installed...'
if subprocess.call(mbr_install_cmd, shell=True) == 0: if subprocess.call(mbr_install_cmd, shell=True) == 0:
config.status_text = 'mbr install is success...' config.status_text = 'mbr install is success...'
log ("\nmbr install is success...\n") log("\nmbr install is success...\n")
if set_boot_flag(usb_disk) is True: if set_boot_flag(usb_disk) is True:
return True return True
else: else:
log ("\nFailed to install default syslinux...\n") log("\nFailed to install default syslinux...\n")
config.status_text = 'Failed to install default syslinux...' config.status_text = 'Failed to install default syslinux...'
return False return False
elif platform.system() == "Windows": elif platform.system() == "Windows":
syslinux = resource_path(os.path.join(multibootusb_host_dir(), "syslinux", "bin", "syslinux4.exe")) syslinux = resource_path(os.path.join(multibootusb_host_dir(), "syslinux", "bin", "syslinux4.exe"))
log ('Executing ==>' + syslinux + ' -maf -d multibootusb ' + usb_disk) log('Executing ==>' + syslinux + ' -maf -d multibootusb ' + usb_disk)
config.status_text = 'Installing default syslinux version 4...' config.status_text = 'Installing default syslinux version 4...'
if subprocess.call(syslinux + ' -maf -d multibootusb ' + usb_disk, shell=True) == 0: if subprocess.call(syslinux + ' -maf -d multibootusb ' + usb_disk, shell=True) == 0:
config.status_text = 'Default syslinux successfully installed...' config.status_text = 'Default syslinux successfully installed...'
log ("\nDefault syslinux install is success...\n") log("\nDefault syslinux install is success...\n")
return True return True
else: else:
log ("\nFailed to install default syslinux...\n") log("\nFailed to install default syslinux...\n")
config.status_text = 'Failed to install default syslinux...' config.status_text = 'Failed to install default syslinux...'
return False return False
@ -115,7 +115,7 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
usb_mount = usb_details['mount_point'] usb_mount = usb_details['mount_point']
isolinux_bin_dir(iso_link) isolinux_bin_dir(iso_link)
if isolinux_bin_exist(iso_link) is False: if isolinux_bin_exist(iso_link) is False:
log ('Distro does not use isolinux for booting ISO.') log('Distro does not use isolinux for booting ISO.')
else: else:
# iso_cfg_ext_dir = os.path.join(multibootusb_host_dir(), "iso_cfg_ext_dir") # iso_cfg_ext_dir = os.path.join(multibootusb_host_dir(), "iso_cfg_ext_dir")
_iso_cfg_ext_dir = iso_cfg_ext_dir() _iso_cfg_ext_dir = iso_cfg_ext_dir()
@ -126,7 +126,7 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
log('Distro uses really old isolinux. Installing version 3 instead of 2.') log('Distro uses really old isolinux. Installing version 3 instead of 2.')
config.syslinux_version = '3' config.syslinux_version = '3'
if distro == "generic" or distro == "alpine": if distro in ["generic", "alpine"]:
install_dir = usb_mount install_dir = usb_mount
distro_syslinux_install_dir = os.path.join(usb_mount, iso_linux_bin_dir.strip("/")).replace(usb_mount, "") distro_syslinux_install_dir = os.path.join(usb_mount, iso_linux_bin_dir.strip("/")).replace(usb_mount, "")
distro_sys_install_bs = os.path.join(install_dir, iso_linux_bin_dir.strip("/"), distro + '.bs') distro_sys_install_bs = os.path.join(install_dir, iso_linux_bin_dir.strip("/"), distro + '.bs')
@ -134,8 +134,8 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
install_dir = os.path.join(usb_mount, "multibootusb", iso_basename(iso_link)) install_dir = os.path.join(usb_mount, "multibootusb", iso_basename(iso_link))
distro_syslinux_install_dir = os.path.join(install_dir, iso_linux_bin_dir.strip("/")).replace(usb_mount, "") distro_syslinux_install_dir = os.path.join(install_dir, iso_linux_bin_dir.strip("/")).replace(usb_mount, "")
distro_sys_install_bs = os.path.join(install_dir, iso_linux_bin_dir.strip("/"), distro + '.bs') distro_sys_install_bs = os.path.join(install_dir, iso_linux_bin_dir.strip("/"), distro + '.bs')
# log (distro_sys_install_bs) # log(distro_sys_install_bs)
# log (distro_syslinux_install_dir) # log(distro_syslinux_install_dir)
if usb_fs in syslinux_fs: if usb_fs in syslinux_fs:
if config.syslinux_version == str(3): if config.syslinux_version == str(3):
@ -155,22 +155,22 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
subprocess.call('chmod +x ' + syslinux_path, shell=True) == 0 subprocess.call('chmod +x ' + syslinux_path, shell=True) == 0
sys_cmd = syslinux_path + option + quote(distro_syslinux_install_dir) + ' ' + usb_disk sys_cmd = syslinux_path + option + quote(distro_syslinux_install_dir) + ' ' + usb_disk
dd_cmd = 'dd if=' + usb_disk + ' ' + 'of=' + quote(distro_sys_install_bs) + ' count=1' dd_cmd = 'dd if=' + usb_disk + ' ' + 'of=' + quote(distro_sys_install_bs) + ' count=1'
log ("Executing ==> " + sys_cmd) log("Executing ==> " + sys_cmd)
config.status_text = 'Installing distro specific syslinux...' config.status_text = 'Installing distro specific syslinux...'
if subprocess.call(sys_cmd, shell=True) == 0: if subprocess.call(sys_cmd, shell=True) == 0:
config.status_text = 'Syslinux install on distro directory is successful...' config.status_text = 'Syslinux install on distro directory is successful...'
log ("\nSyslinux install on distro directory is successful...\n") log("\nSyslinux install on distro directory is successful...\n")
log ('Executing ==> ' + dd_cmd + '\n') log('Executing ==> ' + dd_cmd + '\n')
config.status_text = 'Copying boot sector...' config.status_text = 'Copying boot sector...'
if subprocess.call(dd_cmd, shell=True) == 0: if subprocess.call(dd_cmd, shell=True) == 0:
config.status_text = 'Bootsector copy is successful...' config.status_text = 'Bootsector copy is successful...'
log ("\nBootsector copy is successful...\n") log("\nBootsector copy is successful...\n")
else: else:
config.status_text = 'Failed to copy boot sector...' config.status_text = 'Failed to copy boot sector...'
log ("\nFailed to copy boot sector...\n") log("\nFailed to copy boot sector...\n")
else: else:
config.status_text = 'Failed to install syslinux on distro directory...' config.status_text = 'Failed to install syslinux on distro directory...'
log ("\nFailed to install syslinux on distro directory...\n") log("\nFailed to install syslinux on distro directory...\n")
elif platform.system() == "Windows": elif platform.system() == "Windows":
syslinux_path = resource_path(os.path.join(multibootusb_host_dir(), "syslinux", "bin")) + \ syslinux_path = resource_path(os.path.join(multibootusb_host_dir(), "syslinux", "bin")) + \
@ -183,10 +183,10 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
config.status_text = 'Installing distro specific syslinux...' config.status_text = 'Installing distro specific syslinux...'
if subprocess.call(sys_cmd, shell=True) == 0: if subprocess.call(sys_cmd, shell=True) == 0:
config.status_text = 'Syslinux install on distro directory is successful...' config.status_text = 'Syslinux install on distro directory is successful...'
log ("\nSyslinux install was successful on distro directory...\n") log("\nSyslinux install was successful on distro directory...\n")
else: else:
config.status_text = 'Failed to install syslinux on distro directory...' config.status_text = 'Failed to install syslinux on distro directory...'
log ("\nFailed to install syslinux on distro directory...\n") log("\nFailed to install syslinux on distro directory...\n")
elif usb_fs in extlinux_fs: elif usb_fs in extlinux_fs:
if platform.system() == "Linux": if platform.system() == "Linux":
distro_syslinux_install_dir = os.path.join(install_dir, iso_linux_bin_dir.strip("/")) distro_syslinux_install_dir = os.path.join(install_dir, iso_linux_bin_dir.strip("/"))
@ -195,18 +195,18 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
dd_cmd = 'dd if=' + usb_disk + ' ' + 'of=' + quote(distro_sys_install_bs) + ' count=1' dd_cmd = 'dd if=' + usb_disk + ' ' + 'of=' + quote(distro_sys_install_bs) + ' count=1'
if os.access(syslinux_path, os.X_OK) is False: if os.access(syslinux_path, os.X_OK) is False:
subprocess.call('chmod +x ' + syslinux_path, shell=True) == 0 subprocess.call('chmod +x ' + syslinux_path, shell=True) == 0
log ("Executing ==> " + ext_cmd) log("Executing ==> " + ext_cmd)
if subprocess.call(ext_cmd, shell=True) == 0: if subprocess.call(ext_cmd, shell=True) == 0:
log ("\nSyslinux install on distro directory is successful...\n") log("\nSyslinux install on distro directory is successful...\n")
log ('Executing ==> ' + dd_cmd, '\n') log('Executing ==> ' + dd_cmd, '\n')
if subprocess.call(dd_cmd, shell=True) == 0: if subprocess.call(dd_cmd, shell=True) == 0:
log ("\nBootsector copy is successful...\n") log("\nBootsector copy is successful...\n")
else: else:
log ("\nFailed to install syslinux on distro directory...\n") log("\nFailed to install syslinux on distro directory...\n")
if __name__ == '__main__': if __name__ == '__main__':
if os.geteuid() != 0: if os.geteuid() != 0:
log ('Please running this script with sudo/root/admin privilage.') log('Please running this script with sudo/root/admin privilage.')
exit(1) exit(1)
else: else:
syslinux_distro_dir('/dev/sdb1', '../../../DISTROS/2016/debian-live-8.3.0-amd64-lxde-desktop.iso', 'debian') syslinux_distro_dir('/dev/sdb1', '../../../DISTROS/2016/debian-live-8.3.0-amd64-lxde-desktop.iso', 'debian')

View File

@ -53,14 +53,14 @@ def update_distro_cfg_files(iso_link, usb_disk, distro, persistence=0):
'ignore_bootid root=UUID=' + usb_uuid + ' live-media-path=/multibootusb/' 'ignore_bootid root=UUID=' + usb_uuid + ' live-media-path=/multibootusb/'
+ iso_basename(iso_link) + '/casper', string) + iso_basename(iso_link) + '/casper', string)
string = re.sub(r'ui gfxboot', '#ui gfxboot', string) string = re.sub(r'ui gfxboot', '#ui gfxboot', string)
if not persistence == 0: if persistence != 0:
string = re.sub(r'boot=casper', 'boot=casper persistent persistent-path=/multibootusb/' + string = re.sub(r'boot=casper', 'boot=casper persistent persistent-path=/multibootusb/' +
iso_basename(iso_link) + "/", string) iso_basename(iso_link) + "/", string)
elif distro == "debian" or distro == "debian-install": elif distro in ["debian", "debian-install"]:
string = re.sub(r'boot=live', 'boot=live ignore_bootid live-media-path=/multibootusb/' + string = re.sub(r'boot=live', 'boot=live ignore_bootid live-media-path=/multibootusb/' +
iso_basename(iso_link) + '/live', string) iso_basename(iso_link) + '/live', string)
if not persistence == 0: if persistence != 0:
string = re.sub(r'boot=live', 'boot=live persistent persistent-path=/multibootusb/' + string = re.sub(r'boot=live', 'boot=live persistent persistent-path=/multibootusb/' +
iso_basename(iso_link) + "/", string) iso_basename(iso_link) + "/", string)
elif distro == 'grml': elif distro == 'grml':
@ -81,7 +81,7 @@ def update_distro_cfg_files(iso_link, usb_disk, distro, persistence=0):
string = re.sub(r'initrd=', 'rd.live.dir=/multibootusb/' + iso_basename(iso_link) + string = re.sub(r'initrd=', 'rd.live.dir=/multibootusb/' + iso_basename(iso_link) +
'/LiveOS initrd=', string) '/LiveOS initrd=', string)
if not persistence == 0: if persistence != 0:
if re.search(r'liveimg', string, re.I): if re.search(r'liveimg', string, re.I):
string = re.sub(r'liveimg', 'liveimg overlay=UUID=' + usb_uuid, string) string = re.sub(r'liveimg', 'liveimg overlay=UUID=' + usb_uuid, string)
elif re.search(r'rd.live.image', string, re.I): elif re.search(r'rd.live.image', string, re.I):
@ -152,7 +152,7 @@ def update_distro_cfg_files(iso_link, usb_disk, distro, persistence=0):
rows.append(line) rows.append(line)
string = ''.join(rows) string = ''.join(rows)
elif distro == "arch" or distro == "chakra": elif distro in ["arch", "chakra"]:
string = re.sub(r'isolabel=\S*', string = re.sub(r'isolabel=\S*',
'isodevice=/dev/disk/by-uuid/' + usb_uuid, string, flags=re.I) 'isodevice=/dev/disk/by-uuid/' + usb_uuid, string, flags=re.I)
string = re.sub(r'isobasedir=', string = re.sub(r'isobasedir=',
@ -168,7 +168,7 @@ def update_distro_cfg_files(iso_link, usb_disk, distro, persistence=0):
string = re.sub(r'append', string = re.sub(r'append',
'append kdeosisobasedir=/multibootusb/' + iso_basename(iso_link) + '/kdeos/', string, flags=re.I) 'append kdeosisobasedir=/multibootusb/' + iso_basename(iso_link) + '/kdeos/', string, flags=re.I)
string = re.sub(r'ui gfxboot', '# ui gfxboot', string) # Bug in the isolinux package string = re.sub(r'ui gfxboot', '# ui gfxboot', string) # Bug in the isolinux package
elif distro == "suse" or distro == "opensuse": elif distro in ["suse", "opensuse"]:
if re.search(r'opensuse_12', string, re.I): if re.search(r'opensuse_12', string, re.I):
string = re.sub(r'append', string = re.sub(r'append',
'append loader=syslinux isofrom_system=/dev/disk/by-uuid/' + usb_uuid + ":/" + 'append loader=syslinux isofrom_system=/dev/disk/by-uuid/' + usb_uuid + ":/" +
@ -256,7 +256,7 @@ def update_distro_cfg_files(iso_link, usb_disk, distro, persistence=0):
gen.log('EFI image does not exist. Copying now...') gen.log('EFI image does not exist. Copying now...')
shutil.copy2(resource_path(os.path.join("data", "EFI", "BOOT", "bootx64.efi")), shutil.copy2(resource_path(os.path.join("data", "EFI", "BOOT", "bootx64.efi")),
os.path.join(config.usb_mount, 'EFI', 'BOOT')) os.path.join(config.usb_mount, 'EFI', 'BOOT'))
elif not gen.grub_efi_exist(efi_grub_img) is True: elif gen.grub_efi_exist(efi_grub_img) is False:
gen.log('EFI image overwritten by distro install. Replacing it now...') gen.log('EFI image overwritten by distro install. Replacing it now...')
shutil.copy2(resource_path(os.path.join("data", "EFI", "BOOT", "bootx64.efi")), shutil.copy2(resource_path(os.path.join("data", "EFI", "BOOT", "bootx64.efi")),
os.path.join(config.usb_mount, 'EFI', 'BOOT')) os.path.join(config.usb_mount, 'EFI', 'BOOT'))
@ -279,7 +279,7 @@ def update_mbusb_cfg_file(iso_link, usb_uuid, usb_mount, distro):
if distro == "hbcd": if distro == "hbcd":
if os.path.exists(os.path.join(usb_mount, "multibootusb", "menu.lst")): if os.path.exists(os.path.join(usb_mount, "multibootusb", "menu.lst")):
_config_file = os.path.join(usb_mount, "multibootusb", "menu.lst") _config_file = os.path.join(usb_mount, "multibootusb", "menu.lst")
config_file = open(_config_file,"w") config_file = open(_config_file, "w")
string = re.sub(r'/HBCD', '/multibootusb/' + iso_basename(iso_link) + '/HBCD', _config_file) string = re.sub(r'/HBCD', '/multibootusb/' + iso_basename(iso_link) + '/HBCD', _config_file)
config_file.write(string) config_file.write(string)
config_file.close() config_file.close()
@ -360,7 +360,7 @@ def update_mbusb_cfg_file(iso_link, usb_uuid, usb_mount, distro):
if isolinux_bin_exist(config.image_path) is True: if isolinux_bin_exist(config.image_path) is True:
if distro == "generic": if distro == "generic":
distro_syslinux_install_dir = isolinux_bin_dir(iso_link) distro_syslinux_install_dir = isolinux_bin_dir(iso_link)
if not isolinux_bin_dir(iso_link) == "/": if isolinux_bin_dir(iso_link) != "/":
distro_sys_install_bs = os.path.join(usb_mount, isolinux_bin_dir(iso_link)) + '/' + distro + '.bs' distro_sys_install_bs = os.path.join(usb_mount, isolinux_bin_dir(iso_link)) + '/' + distro + '.bs'
else: else:
distro_sys_install_bs = '/' + distro + '.bs' distro_sys_install_bs = '/' + distro + '.bs'

View File

@ -353,9 +353,9 @@ def win_disk_details(disk_drive):
oFS = win32com.client.Dispatch("Scripting.FileSystemObject") oFS = win32com.client.Dispatch("Scripting.FileSystemObject")
d = oFS.GetDrive(oFS.GetDriveName(oFS.GetAbsolutePathName(selected_usb_part))) d = oFS.GetDrive(oFS.GetDriveName(oFS.GetAbsolutePathName(selected_usb_part)))
selected_usb_device = d.DriveLetter selected_usb_device = d.DriveLetter
if d.DriveType is 1: if d.DriveType == 1:
devtype = "Removable Disk" devtype = "Removable Disk"
elif d.DriveType is 2: elif d.DriveType == 2:
devtype = "Fixed Disk" devtype = "Fixed Disk"
label = (d.VolumeName).strip() label = (d.VolumeName).strip()
if not label.strip(): if not label.strip():