From 36a7ec3d2e8486f2de6b51c09f22b0911335ed9f Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Wed, 17 Jan 2024 11:53:08 +0000 Subject: [PATCH] Expose hostname in settings manager I've added a `hostname` property to the settings manager. --- .../things/settings_manager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/openflexure_microscope_server/things/settings_manager.py b/src/openflexure_microscope_server/things/settings_manager.py index 24ed8052..7514d7f1 100644 --- a/src/openflexure_microscope_server/things/settings_manager.py +++ b/src/openflexure_microscope_server/things/settings_manager.py @@ -102,6 +102,11 @@ class SettingsManager(Thing): self.thing_settings["microscope_id"] = str(uuid4()) return UUID(self.thing_settings["microscope_id"]) + @thing_property + def hostname(self) -> str: + """The hostname of the microscope, as reported by its operating system.""" + return gethostname() + @thing_action def get_things_state(self, metadata_getter: GetThingStates) -> Mapping: """Metadata summarising the current state of all Things in the server""" @@ -119,7 +124,7 @@ class SettingsManager(Thing): @property def thing_state(self) -> Mapping: state = { - "hostname": gethostname(), + "hostname": self.hostname, "microscope-uuid": str(self.microscope_id), } metadata = self.external_metadata