From b111a4e68065afa9d94c54f81d19ec6454108779 Mon Sep 17 00:00:00 2001 From: samuelmcdermott Date: Wed, 21 Oct 2020 18:42:41 +0100 Subject: [PATCH 1/4] Only save configuration if successfully load new stage type --- openflexure_microscope/microscope.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openflexure_microscope/microscope.py b/openflexure_microscope/microscope.py index 824ce971..c115c869 100644 --- a/openflexure_microscope/microscope.py +++ b/openflexure_microscope/microscope.py @@ -144,6 +144,9 @@ class Microscope: try: logging.info("Trying SangaStage") self.stage = SangaStage(port=stage_port) + logging.info("Saving new SangaStage type configuration") + configuration["stage"]["type"] = stage_type + self.configuration_file.save(configuration) except Exception as e: # pylint: disable=W0703 logging.error(e) logging.warning("No compatible Sangaboard hardware found.") @@ -151,16 +154,15 @@ class Microscope: try: logging.info("Trying SangaDeltaStage") self.stage = SangaDeltaStage(port=stage_port) - + logging.info("Saving new SangaDeltaStage type configuration") + configuration["stage"]["type"] = stage_type + self.configuration_file.save(configuration) except Exception as e: # pylint: disable=W0703 logging.error(e) logging.warning("No compatible Sangaboard hardware found.") else: logging.warning("The stage type is incorrectly defined.") - logging.info("Saving new stage type configuration") - configuration["stage"]["type"] = stage_type - self.configuration_file.save(configuration) def has_real_stage(self) -> bool: """ From 97ff8d4049b6ca8ba2d35e7305c579cd6b299025 Mon Sep 17 00:00:00 2001 From: samuelmcdermott Date: Wed, 21 Oct 2020 18:43:13 +0100 Subject: [PATCH 2/4] Add header to put request to ensure string is sent --- .../settingsComponents/stageSettings.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/openflexure_microscope/api/static/src/components/viewComponents/settingsComponents/stageSettings.vue b/openflexure_microscope/api/static/src/components/viewComponents/settingsComponents/stageSettings.vue index 48bb8a72..9a98f2b3 100644 --- a/openflexure_microscope/api/static/src/components/viewComponents/settingsComponents/stageSettings.vue +++ b/openflexure_microscope/api/static/src/components/viewComponents/settingsComponents/stageSettings.vue @@ -4,7 +4,7 @@

Stage settings

@@ -18,7 +18,7 @@ type="submit" class="uk-button uk-button-primary uk-width-1-1" > - Change stage type + Change stage geometry
@@ -70,11 +70,15 @@ export default { setStageType: function() { console.log("Setting stage type"); axios - .put(this.stageTypeUri, this.stageType) + .put(this.stageTypeUri, this.stageType,{ + headers: { + 'Content-Type': 'text/plain', + } + }) .then(response => { this.stageType = response.data; console.log("Stage type set to " + this.stageType); - this.modalNotify("Stage type changed."); + this.modalNotify("Stage geometry changed."); }) .catch(error => { this.modalError(error); From 2f08bd37d39c82d06f338a0cb993463709e82bdc Mon Sep 17 00:00:00 2001 From: Samuel McDermott Date: Tue, 27 Oct 2020 16:16:58 +0000 Subject: [PATCH 3/4] Use `application/json` for put --- .../viewComponents/settingsComponents/stageSettings.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflexure_microscope/api/static/src/components/viewComponents/settingsComponents/stageSettings.vue b/openflexure_microscope/api/static/src/components/viewComponents/settingsComponents/stageSettings.vue index 9a98f2b3..5a7ed4a1 100644 --- a/openflexure_microscope/api/static/src/components/viewComponents/settingsComponents/stageSettings.vue +++ b/openflexure_microscope/api/static/src/components/viewComponents/settingsComponents/stageSettings.vue @@ -72,7 +72,7 @@ export default { axios .put(this.stageTypeUri, this.stageType,{ headers: { - 'Content-Type': 'text/plain', + 'Content-Type': 'application/json', } }) .then(response => { From 76094b2cc28e939144e03e36a3234dc13040cbc1 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Tue, 27 Oct 2020 17:11:41 +0000 Subject: [PATCH 4/4] Code formatting --- openflexure_microscope/microscope.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openflexure_microscope/microscope.py b/openflexure_microscope/microscope.py index c115c869..1035102a 100644 --- a/openflexure_microscope/microscope.py +++ b/openflexure_microscope/microscope.py @@ -163,7 +163,6 @@ class Microscope: else: logging.warning("The stage type is incorrectly defined.") - def has_real_stage(self) -> bool: """ Check if a real (non-mock) stage is currently attached.