Skip to content

Commit c63e6d9

Browse files
ZipFile: add support for deflate.RAW compressed mpk/zip files
1 parent f38b12e commit c63e6d9

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

internal_filesystem/lib/zipfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ def compress(self, data):
799799
# wbits for DeflateIO is 5 through 15 inclusive
800800
wbits = 5+self.compresslevel
801801
stream = io.BytesIO()
802-
with deflate.DeflateIO(stream, deflate.ZLIB, wbits) as d:
802+
with deflate.DeflateIO(stream, deflate.RAW, wbits) as d:
803803
d.write(data)
804804
compressed = stream.getvalue()
805805
return compressed
@@ -818,7 +818,7 @@ def __init__(self):
818818
def decompress(self, data):
819819
stream = io.BytesIO(data)
820820
try:
821-
with deflate.DeflateIO(stream, deflate.AUTO) as d:
821+
with deflate.DeflateIO(stream, deflate.RAW, 15) as d:
822822
decompressed = d.read()
823823
except EOFError:
824824
return b''

internal_filesystem/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
try:
3232
import mpos.main # noqa: F401
3333
except Exception as e:
34-
sys.print_exception(e)
34+
print("Error importing mpos.main, sleeping 5 seconds...")
3535
import time
36-
print(f"Error in mpos.main, sleep for 5 seconds and end then...")
37-
time.sleep(5)
36+
time.sleep(5) # sleep so the user has time to connect to serial console
37+
sys.print_exception(e) # print it after the sleep so user can see it on serial console
38+
print("MicroPythonOS exiting.")
3839

0 commit comments

Comments
 (0)