Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Fix log-reader for Python3 (#3580)
Browse files Browse the repository at this point in the history
* Fix log-reader for Python3

Signed-off-by: thinker0 <[email protected]>

* typo

Signed-off-by: thinker0 <[email protected]>

* Revert commit

Co-authored-by: thinker0 <[email protected]>
  • Loading branch information
thinker0 and thinker0 authored Jul 26, 2020
1 parent d9c06bd commit 0c9b209
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions heron/shell/src/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ def read_chunk(filename, offset=-1, length=-1, escape_data=False):
if length == -1:
length = fstat.st_size - offset

with open(filename, "r") as fp:
with open(filename, "rb") as fp:
fp.seek(offset)
try:
data = fp.read(length)
except IOError:
return {}

if data:
data = _escape_data(data) if escape_data else data
# use permissive decoding and escaping if escape_data is set, otherwise use strict decoding
data = _escape_data(data) if escape_data else data.decode()
return dict(offset=offset, length=len(data), data=data)

return dict(offset=offset, length=0)
Expand Down

0 comments on commit 0c9b209

Please sign in to comment.