Merge branch 'bugfix/unicode-terminal' into 'dev'

Fix unicode chars in terminal & logs w/ textiowrapper

See merge request crafty-controller/crafty-4!689
This commit is contained in:
Iain Powrie 2024-01-16 20:07:17 +00:00
commit 27678e93ca
3 changed files with 8 additions and 3 deletions

View File

@ -7,6 +7,7 @@
- Fix bukkit and downstream fork MOTD crash ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/686))
- Fix bug where invalid server Id leads to stack ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/690))
- Fix indent on public status check box ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/691))
- Fix unicode chars in terminal & logs w/ textiowrapper ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/689))
### Tweaks
- Refactor Forge server initialisation flow for newer versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/687))
- Remove scroll bars from player management ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/693))

View File

@ -1,5 +1,6 @@
from contextlib import redirect_stderr
import os
import io
import re
import shutil
import time
@ -116,14 +117,17 @@ class ServerOutBuf:
ServerOutBuf.lines[self.server_id].pop(0)
def check(self):
text_wrapper = io.TextIOWrapper(
self.proc.stdout, encoding="UTF-8", errors="ignore", newline=""
)
while True:
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
# processing it later, reads are kind of expensive as a syscall
self.process_byte(char)
else:
flush = self.proc.stdout.read().decode("utf-8", "ignore")
flush = text_wrapper.read() # modified
for char in flush:
self.process_byte(char)
break

View File

@ -192,7 +192,7 @@
const token = getCookie("_xsrf")
let colors = true;
if (!$("#stop_scroll").is(':checked')) {
let res = await fetch(`/api/v2/servers/${serverId}/logs?colors=${colors}`, {
let res = await fetch(`/api/v2/servers/${serverId}/logs?colors=${colors}&file=true`, {
method: 'GET',
headers: {
'X-XSRFToken': token