Make gzip Python2.7 compatible

This commit is contained in:
Hadinger 2020-01-07 22:32:48 +01:00
parent 8db49a0fe3
commit 63b6cee1a1
1 changed files with 4 additions and 10 deletions

View File

@ -13,17 +13,11 @@ def bin_gzip(source, target, env):
gzip_file = "{}firmware{}{}.bin.gz".format(OUTPUT_DIR, os.path.sep, variant) gzip_file = "{}firmware{}{}.bin.gz".format(OUTPUT_DIR, os.path.sep, variant)
# check if new target files exist and remove if necessary # check if new target files exist and remove if necessary
for f in [gzip_file]: if os.path.isfile(gzip_file): os.remove(gzip_file)
if os.path.isfile(f):
os.remove(f)
# write gzip firmware file # write gzip firmware file
fp = open(bin_file,"rb") with open(bin_file,"rb") as fp:
data = fp.read() with gzip.open(gzip_file, "wb") as f:
bindata = bytearray(data) shutil.copyfileobj(fp, f)
with gzip.open(gzip_file, "wb") as f:
f.write(bindata)
fp.close()
f.close()
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_gzip]) env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_gzip])