discord-bot/stream_handlers.py
13xforever b09cea6db6 Small fixes here and there
Use usr bot id to check for recursion instead of hardcoded name
More error handling during log parse
Post log analysis results even if it wasn't finished for some reason (e.g. truncated log)
Fix log summary alignment for GPU settings
Tweak product id reges: allow more formats, restrict to known product IDs
2018-02-16 22:57:26 +05:00

20 lines
441 B
Python

import zlib
def stream_text_log(stream):
for chunk in stream.iter_content(chunk_size=1024):
yield chunk
def stream_gzip_decompress(stream):
dec = zlib.decompressobj(32 + zlib.MAX_WBITS) # offset 32 to skip the header
for chunk in stream:
try:
rv = dec.decompress(chunk)
if rv:
yield rv
del rv
except zlib.error as zlr:
pass
del dec