Raise better exceptions/errors when a filepath given to makepkginfo doesn't exist or can't be read. Addresses #960.

This commit is contained in:
Greg Neagle
2019-11-14 09:57:00 -08:00
parent 91f6087751
commit aec2ef7014
+9 -2
View File
@@ -393,7 +393,11 @@ def makepkginfo(installeritem, options):
pkginfo = {}
installs = []
if installeritem and os.path.exists(installeritem):
if installeritem:
if not os.path.exists(installeritem):
raise PkgInfoGenerationError(
"File %s does not exist" % installeritem)
# Check if the item is a mount point for a disk image
if dmgutils.pathIsVolumeMountPoint(installeritem):
# Get the disk image path for the mount point
@@ -405,7 +409,10 @@ def makepkginfo(installeritem, options):
itemhash = "N/A"
if os.path.isfile(installeritem):
itemsize = int(os.path.getsize(installeritem))
itemhash = munkihash.getsha256hash(installeritem)
try:
itemhash = munkihash.getsha256hash(installeritem)
except OSError as err:
raise PkgInfoGenerationError(err)
if pkgutils.hasValidDiskImageExt(installeritem):
if dmgutils.DMGisWritable(installeritem) and options.print_warnings: