From 04bed170a0d5dd212b0fb588b91e6e5c595709fd Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Thu, 31 Jan 2019 16:47:54 +0000 Subject: [PATCH] Added JSON safety to config reads --- openflexure_microscope/api/v1/blueprints/base.py | 4 ++-- openflexure_microscope/microscope.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openflexure_microscope/api/v1/blueprints/base.py b/openflexure_microscope/api/v1/blueprints/base.py index b3a841b9..681fe12d 100644 --- a/openflexure_microscope/api/v1/blueprints/base.py +++ b/openflexure_microscope/api/v1/blueprints/base.py @@ -136,7 +136,7 @@ class ConfigAPI(MicroscopeView): :>header Content-Type: application/json :status 200: state available """ - return jsonify(self.microscope.read_config()) + return jsonify(self.microscope.read_config(json_safe=True)) def post(self): """ @@ -175,7 +175,7 @@ class ConfigAPI(MicroscopeView): self.microscope.write_config(payload.json) self.microscope.save_config() - return jsonify(self.microscope.config) + return jsonify(self.microscope.read_config(json_safe=True)) def construct_blueprint(microscope_obj): diff --git a/openflexure_microscope/microscope.py b/openflexure_microscope/microscope.py index dd6815e8..626be21a 100644 --- a/openflexure_microscope/microscope.py +++ b/openflexure_microscope/microscope.py @@ -200,14 +200,14 @@ class Microscope(object): # Cache config self.rc.write(config) - def read_config(self): + def read_config(self, json_safe=False): """ Read an updated config including camera settings. """ # If attached to a camera if self.camera: # Update camera config params from StreamingCamera object - self.rc.write(self.camera.config) + self.rc.write(self.camera.read_config()) # If attached to a stage if self.stage: @@ -225,7 +225,7 @@ class Microscope(object): self.rc.write(backlash) - return self.rc.read() + return self.rc.read(json_safe=json_safe) def save_config(self): """