grahampugh / macadmin-scripts

Scripts of possible interest to macOS admins
Other
366 stars 46 forks source link

[master] Added check to know whether a file is actually a gzip file or not #25

Closed LcTrKiD closed 4 years ago

grahampugh commented 4 years ago

Hi @LcTrKiD , can you tell me what this fixes? I merged in some changes from Greg's installinstallmacos.py already, but maybe I missed something since then. Could you give me an example of a failed output when this is not there. I ask because I do not like to deviate too much from Greg's version in case I lose the ability to merge upstream changes in the future.

LcTrKiD commented 4 years ago

Sorry @grahampugh, I forgot to add a description.

In my case the catalog, for a reason I can't understand was being downloaded with .gz extension but it wasn't actually a gzip file.

` joaquin  ~/github/macadmin-scripts-grahampugh/macadmin-scripts   master  gl remote: Enumerating objects: 19, done. remote: Counting objects: 100% (19/19), done. remote: Compressing objects: 100% (6/6), done. remote: Total 13 (delta 9), reused 10 (delta 7), pack-reused 0 Unpacking objects: 100% (13/13), done. From https://github.com/grahampugh/macadmin-scripts 42b1840..e45b738 master -> origin/master Updating 42b1840..e45b738 Fast-forward installinstallmacos.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) joaquin  ~/github/macadmin-scripts-grahampugh/macadmin-scripts   master  sudo ./installinstallmacos.py --seedprogram DeveloperSeed Password:

installinstallmacos.py - get macOS installers from the Apple software catalog

This Mac: Model Identifier : MacBookPro14,1

Bridge ID : None Board ID : Mac-REDACTED OS Version : 10.15.6 Build ID : 19G73

Traceback (most recent call last): File "./installinstallmacos.py", line 1205, in main() File "./installinstallmacos.py", line 843, in main su_catalog_url, args.workdir, ignore_cache=args.ignore_cache File "./installinstallmacos.py", line 537, in download_and_parse_sucatalog content = the_file.read() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 260, in read self._read(readsize) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 302, in _read self._read_gzip_header() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 196, in _read_gzip_header raise IOError, 'Not a gzipped file' IOError: Not a gzipped file `

LcTrKiD commented 4 years ago

Btw, I got the same error with Greg's version

grahampugh commented 4 years ago

Thanks, I saw somebody mention an issue with alternative catalogs. I'll take a look.

grahampugh commented 4 years ago

Hi @LcTrKiD Greg fixed this in the upstream installinstallmacos.py in a different way (https://github.com/munki/macadmin-scripts/issues/68), so I don't need this, but thanks for the efforts!

LcTrKiD commented 4 years ago

munki#68 seems like a better solution. Thanks you!