From 7d57a22f01bebf43a9787d26543e3e5e029a8b9e Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 22 Feb 2023 20:29:30 -0500 Subject: un-snake-case --- electron/src/renderer/components/Preferences.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/electron/src/renderer/components/Preferences.vue b/electron/src/renderer/components/Preferences.vue index 19fe670f..f68c942d 100644 --- a/electron/src/renderer/components/Preferences.vue +++ b/electron/src/renderer/components/Preferences.vue @@ -37,7 +37,9 @@ mm - set as default + + set as default + @@ -56,7 +58,9 @@ mm - set as default + + set as default + -- cgit v1.2.3 From 36f0946e2d7ccc7b9736eaac5ebd4852d070eab7 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 22 Feb 2023 21:08:40 -0500 Subject: fix flask json deprecation --- lib/api/server.py | 4 ++-- lib/utils/json.py | 12 +++++++++--- requirements.txt | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/api/server.py b/lib/api/server.py index 626e412e..f9bb6458 100644 --- a/lib/api/server.py +++ b/lib/api/server.py @@ -14,7 +14,7 @@ import requests from flask import Flask, g from werkzeug.serving import make_server -from ..utils.json import InkStitchJSONEncoder +from ..utils.json import InkStitchJSONProvider from .install import install from .simulator import simulator from .stitch_plan import stitch_plan @@ -41,7 +41,7 @@ class APIServer(Thread): cli.show_server_banner = lambda *x: None self.app = Flask(__name__) - self.app.json_encoder = InkStitchJSONEncoder + self.app.json = InkStitchJSONProvider(self.app) self.app.register_blueprint(simulator, url_prefix="/simulator") self.app.register_blueprint(stitch_plan, url_prefix="/stitch_plan") diff --git a/lib/utils/json.py b/lib/utils/json.py index 63b3cfb5..22107c48 100644 --- a/lib/utils/json.py +++ b/lib/utils/json.py @@ -3,10 +3,15 @@ # Copyright (c) 2010 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. -from flask.json import JSONEncoder +from flask.json.provider import DefaultJSONProvider +from ..exceptions import InkstitchException -class InkStitchJSONEncoder(JSONEncoder): +class InkstitchJSONException(InkstitchException): + pass + + +class InkStitchJSONProvider(DefaultJSONProvider): """JSON encoder class that runs __json__ on an object if available. The __json__ method should return a JSON-compatible representation of the @@ -17,4 +22,5 @@ class InkStitchJSONEncoder(JSONEncoder): try: return obj.__json__() except AttributeError: - return JSONEncoder.default(self, obj) + raise InkstitchJSONException( + f"Object of type {obj.__class__.__name__} cannot be serialized to JSON because it does not implement __json__()") diff --git a/requirements.txt b/requirements.txt index dd4a492a..05908f8d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,7 @@ colormath @ git+https://github.com/gtaylor/python-colormath.git@4a076831fd5136f6 stringcase tinycss2 -flask +flask>=2.2.0 fonttools trimesh>=3.15.2 scipy -- cgit v1.2.3