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

Merge pull request #218 from alandmoore/devel

Fix inconsistent indentation
This commit is contained in:
multibootusb 2017-10-24 06:41:15 +05:30 committed by GitHub
commit 9dc593d176
3 changed files with 41 additions and 15 deletions

View File

@ -60,12 +60,20 @@ def iso_size(iso_link):
return os.path.getsize(iso_link) return os.path.getsize(iso_link)
def is_readable(iso_link):
return os.access(iso_link, os.R_OK)
def is_bootable(iso_link): def is_bootable(iso_link):
""" """
Check if an ISO has the ability to boot. Check if an ISO has the ability to boot.
:return: True if ISO is bootable and False if not. :return: True if ISO is bootable and False if not.
""" """
iso9660fs = ISO9660(iso_link) try:
iso9660fs = ISO9660(iso_link)
except IOError as e:
log(str(e))
raise
isBootable = iso9660fs.checkISOBootable() isBootable = iso9660fs.checkISOBootable()
return bool(isBootable) return bool(isBootable)

View File

@ -44,21 +44,21 @@ E_FAILURE = -1
E_DEVICEFILE = -2 # can't write device file E_DEVICEFILE = -2 # can't write device file
class PrimaryVolume(Structure): class PrimaryVolume(Structure):
def __init__(self): def __init__(self):
self.sysIdentifier = "" self.sysIdentifier = ""
self.volIdentifier = "" self.volIdentifier = ""
self.volSize = 0 self.volSize = 0
self.volSeq = 0 self.volSeq = 0
self.blockSize = 0 self.blockSize = 0
self.ptSize = 0 self.ptSize = 0
self.ptLRd = 0 self.ptLRd = 0
self.fsVer = 0 self.fsVer = 0
self.rootLoc = 0 self.rootLoc = 0
self.rootTotal = 0 self.rootTotal = 0
class Rrip(Structure): class Rrip(Structure):
def __init__(self): def __init__(self):
self.offset = -1 self.offset = -1
self.altname = "" self.altname = ""
self.devH = 0 self.devH = 0
self.devL = 0 self.devL = 0
@ -106,7 +106,10 @@ class ISO9660:
f = open(isofile, 'rb') f = open(isofile, 'rb')
except(IOError): except(IOError):
sys.stderr.write("can't open {0}".format(isofile)) sys.stderr.write("can't open {0}".format(isofile))
sys.exit(-1) raise
if os.path.getsize(isofile) == 0:
raise IOError("File {0} appears to be empty".format(isofile))
self.isoFile = f self.isoFile = f
self.priVol = None self.priVol = None
@ -803,4 +806,3 @@ if __name__ == '__main__':
else: else:
gen.log("writeDir(%s)->(%s) with pattern(%s)"%(isodir, o_path, pattern)) gen.log("writeDir(%s)->(%s) with pattern(%s)"%(isodir, o_path, pattern))
sys.exit(iso9660fs.writeDir(isodir, o_path, pattern, r, True)) sys.exit(iso9660fs.writeDir(isodir, o_path, pattern, r, True))

View File

@ -214,6 +214,22 @@ Are you SURE you want to enable it?",
'Img Files(*.img);; All Files(*.*)')[0] 'Img Files(*.img);; All Files(*.*)')[0]
if config.image_path: if config.image_path:
# sanity checks
if not is_readable(config.image_path):
QtWidgets.QMessageBox.critical(
self,
"ISO Not readable",
"Sorry, the file \"{0}\" is not readable.".format(config.image_path)
)
return
if iso_size(config.image_path) == 0:
QtWidgets.QMessageBox.critical(
self,
"ISO is an empty file",
"Sorry, the file \"{0}\" contains no data.".format(config.image_path)
)
return
default_dir_path = os.path.dirname(config.image_path) default_dir_path = os.path.dirname(config.image_path)
gen.write_to_file(preference_file_path, default_dir_path) gen.write_to_file(preference_file_path, default_dir_path)