Skip to content

Commit

Permalink
Open log files in binary mode for Python 3 comp (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
akim-ruslanov committed Aug 12, 2022
1 parent 1d59497 commit e8660d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cuegui/cuegui/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,17 +459,17 @@ def getLastLine(path):
ansiEscape = r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]'

try:
fp = open(path, 'r')
fp = open(path, 'rb')
fp.seek(0, 2)

backseek = min(4096, fp.tell())
fp.seek(-backseek, 1)
buf = fp.read(4096)

newline_pos = buf.rfind("\n",0,len(buf)-1)
newline_pos = buf.rfind(b'\n', 0, len(buf)-1)
fp.close()

line = buf[newline_pos+1:].strip()
line = buf[newline_pos+1:].strip().decode("utf-8")

return re.sub(ansiEscape, "", line)
except IOError:
Expand Down

0 comments on commit e8660d9

Please sign in to comment.