From d0e738c6af970b597a25491ff2b7b6b50641a078 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Wed, 12 Dec 2018 15:02:19 +0000 Subject: [PATCH] Load config and plugins at startup --- openflexure_microscope/api/app.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/openflexure_microscope/api/app.py b/openflexure_microscope/api/app.py index 3a6c184e..413d98cb 100644 --- a/openflexure_microscope/api/app.py +++ b/openflexure_microscope/api/app.py @@ -30,7 +30,8 @@ import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) # Create a dummy microscope object, with no hardware attachments -api_microscope = Microscope(None, None) +openflexurerc = config.load_config() # Load default user config +api_microscope = Microscope(None, None, config=openflexurerc) logging.debug("Created an empty microscope in global.") @@ -66,9 +67,8 @@ for code in default_exceptions: @app.before_first_request def attach_microscope(): # Create the microscope object globally (common to all spawned server threads) - global api_microscope + global api_microscope, openflexurerc logging.debug("First request made. Populating microscope with hardware...") - openflexurerc = config.load_config() # Load default user config logging.debug("Creating camera object...") api_camera = StreamingCamera(config=openflexurerc) @@ -81,9 +81,6 @@ def attach_microscope(): api_stage ) - logging.debug("Attaching plugins to microscope...") - api_microscope.find_plugins() # Automatically find microscope plugins - logging.debug("Microscope successfully attached!")