From da947f16cc42ca93dcf0877c8047e5791428f3d3 Mon Sep 17 00:00:00 2001 From: Chin Yi Han Date: Thu, 27 Jun 2024 14:40:41 +0200 Subject: [PATCH] Added encoding utf8 1. due to windows using its own encoding style, we force encoding = utf8 in core.py Signed-off-by: Chin Yi Han --- core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core.py b/core.py index f0a1106..3901098 100644 --- a/core.py +++ b/core.py @@ -265,7 +265,7 @@ def get(self): print("In designer mode.") # check other data sources: rtsp or rest - with open("style.yaml", 'r') as stream: + with open("style.yaml", 'r', encoding='utf8') as stream: try: style_data = yaml.load(stream, Loader=yaml.Loader) except yaml.YAMLError as exc: @@ -346,7 +346,7 @@ class SaveHandler(tornado.web.RequestHandler): def post(self): json_obj = json_decode(self.request.body) - with open("style.yaml", 'wb') as output: + with open("style.yaml", 'wb', encoding='utf8') as output: output.write(yaml.safe_dump(json_obj, encoding='utf-8', allow_unicode=True, default_flow_style=False)) response = {"success": "Data entry inserted."} @@ -366,7 +366,7 @@ def options(self, *args): def get(self): #print( "In status mode.") - with open("style.yaml", 'r') as stream: + with open("style.yaml", 'r', encoding='utf8') as stream: try: style_data = yaml.load(stream, Loader=yaml.Loader) except yaml.YAMLError as exc: @@ -386,7 +386,7 @@ def get(self): class GetDataHandler(tornado.web.RequestHandler): def get(self): - with open("style.yaml", 'r') as stream: + with open("style.yaml", 'r', encoding='utf8') as stream: try: style_data = yaml.load(stream, Loader=yaml.Loader) except yaml.YAMLError as exc: