mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix unicode chars in terminal w/ texitiowrapper
This commit is contained in:
parent
1d32afa09d
commit
9d319b7460
@ -1,5 +1,6 @@
|
|||||||
from contextlib import redirect_stderr
|
from contextlib import redirect_stderr
|
||||||
import os
|
import os
|
||||||
|
import io
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
@ -115,14 +116,17 @@ class ServerOutBuf:
|
|||||||
ServerOutBuf.lines[self.server_id].pop(0)
|
ServerOutBuf.lines[self.server_id].pop(0)
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
|
text_wrapper = io.TextIOWrapper(
|
||||||
|
self.proc.stdout, encoding="UTF-8", errors="ignore", newline=""
|
||||||
|
)
|
||||||
while True:
|
while True:
|
||||||
if self.proc.poll() is None:
|
if self.proc.poll() is None:
|
||||||
char = self.proc.stdout.read(1).decode("utf-8", "ignore")
|
char = text_wrapper.read(1) # modified
|
||||||
# TODO: we may want to benchmark reading in blocks and userspace
|
# TODO: we may want to benchmark reading in blocks and userspace
|
||||||
# processing it later, reads are kind of expensive as a syscall
|
# processing it later, reads are kind of expensive as a syscall
|
||||||
self.process_byte(char)
|
self.process_byte(char)
|
||||||
else:
|
else:
|
||||||
flush = self.proc.stdout.read().decode("utf-8", "ignore")
|
flush = text_wrapper.read() # modified
|
||||||
for char in flush:
|
for char in flush:
|
||||||
self.process_byte(char)
|
self.process_byte(char)
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user