Loading openflexure_microscope/api/app.py +16 −11 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ from labthings import create_app from labthings.extensions import find_extensions from labthings.views import View from openflexure_microscope.api.microscope import default_microscope as api_microscope from openflexure_microscope.microscope import Microscope from openflexure_microscope.api.utilities import init_default_extensions, list_routes from openflexure_microscope.api.v2 import views from openflexure_microscope.json import JSONEncoder Loading @@ -39,11 +39,7 @@ from openflexure_microscope.paths import ( logs_file_path, ) # Handle logging access_log = logging.getLogger("werkzeug") # Block the access logs from propagating up to the root logger access_log.propagate = False # Log files ROOT_LOGFILE = logs_file_path("openflexure_microscope.log") ACCESS_LOGFILE = logs_file_path("openflexure_microscope.access.log") Loading @@ -52,8 +48,12 @@ formatter = logging.Formatter( "[%(asctime)s] [%(threadName)s] [%(levelname)s] %(message)s" ) # Our WSGI server uses Werkzeug, so use that for the access log access_log = logging.getLogger("werkzeug") # Block the access logs from propagating up to the root logger access_log.propagate = False # Create file handler # Create error log file handler fh = logging.handlers.RotatingFileHandler( ROOT_LOGFILE, maxBytes=1_000_000, backupCount=5 ) Loading @@ -76,8 +76,14 @@ access_log.addHandler(afh) # Log server paths being used logging.info("Running with data path %s", OPENFLEXURE_VAR_PATH) logging.info("Creating app") # Create the microscope object api_microscope = Microscope() logging.debug("Restoring captures...") api_microscope.captures.rebuild_captures() logging.debug("Microscope successfully attached!") # Create flask app logging.info("Creating app") app, labthing = create_app( __name__, prefix="/api/v2", Loading @@ -95,7 +101,7 @@ cors = CORS(app) labthing.json_encoder = JSONEncoder app.json_encoder = JSONEncoder # Attach lab devices # Add the microscope object to LabThings so extensions can access it labthing.add_component(api_microscope, "org.openflexure.microscope") # Attach extensions Loading Loading @@ -129,7 +135,6 @@ labthing.add_root_link(views.ConfigurationProperty, "instrumentConfiguration") # Attach stage resources labthing.add_view(views.StageTypeProperty, "/instrument/stage/type") # Attach streams resources labthing.add_view(views.MjpegStream, "/streams/mjpeg") labthing.add_view(views.SnapshotStream, "/streams/snapshot") Loading @@ -142,7 +147,7 @@ for name, action in views.enabled_root_actions().items(): rule = action["rule"] labthing.add_view(view_class, f"/actions{rule}") # Add log file view # Add log file download view class LogFileView(View): def get(self): """ Loading openflexure_microscope/api/microscope.pydeleted 100644 → 0 +0 −11 Original line number Diff line number Diff line import logging from openflexure_microscope.microscope import Microscope default_microscope = Microscope() # Restore loaded capture array to camera object logging.debug("Restoring captures...") default_microscope.captures.rebuild_captures() logging.debug("Microscope successfully attached!") Loading
openflexure_microscope/api/app.py +16 −11 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ from labthings import create_app from labthings.extensions import find_extensions from labthings.views import View from openflexure_microscope.api.microscope import default_microscope as api_microscope from openflexure_microscope.microscope import Microscope from openflexure_microscope.api.utilities import init_default_extensions, list_routes from openflexure_microscope.api.v2 import views from openflexure_microscope.json import JSONEncoder Loading @@ -39,11 +39,7 @@ from openflexure_microscope.paths import ( logs_file_path, ) # Handle logging access_log = logging.getLogger("werkzeug") # Block the access logs from propagating up to the root logger access_log.propagate = False # Log files ROOT_LOGFILE = logs_file_path("openflexure_microscope.log") ACCESS_LOGFILE = logs_file_path("openflexure_microscope.access.log") Loading @@ -52,8 +48,12 @@ formatter = logging.Formatter( "[%(asctime)s] [%(threadName)s] [%(levelname)s] %(message)s" ) # Our WSGI server uses Werkzeug, so use that for the access log access_log = logging.getLogger("werkzeug") # Block the access logs from propagating up to the root logger access_log.propagate = False # Create file handler # Create error log file handler fh = logging.handlers.RotatingFileHandler( ROOT_LOGFILE, maxBytes=1_000_000, backupCount=5 ) Loading @@ -76,8 +76,14 @@ access_log.addHandler(afh) # Log server paths being used logging.info("Running with data path %s", OPENFLEXURE_VAR_PATH) logging.info("Creating app") # Create the microscope object api_microscope = Microscope() logging.debug("Restoring captures...") api_microscope.captures.rebuild_captures() logging.debug("Microscope successfully attached!") # Create flask app logging.info("Creating app") app, labthing = create_app( __name__, prefix="/api/v2", Loading @@ -95,7 +101,7 @@ cors = CORS(app) labthing.json_encoder = JSONEncoder app.json_encoder = JSONEncoder # Attach lab devices # Add the microscope object to LabThings so extensions can access it labthing.add_component(api_microscope, "org.openflexure.microscope") # Attach extensions Loading Loading @@ -129,7 +135,6 @@ labthing.add_root_link(views.ConfigurationProperty, "instrumentConfiguration") # Attach stage resources labthing.add_view(views.StageTypeProperty, "/instrument/stage/type") # Attach streams resources labthing.add_view(views.MjpegStream, "/streams/mjpeg") labthing.add_view(views.SnapshotStream, "/streams/snapshot") Loading @@ -142,7 +147,7 @@ for name, action in views.enabled_root_actions().items(): rule = action["rule"] labthing.add_view(view_class, f"/actions{rule}") # Add log file view # Add log file download view class LogFileView(View): def get(self): """ Loading
openflexure_microscope/api/microscope.pydeleted 100644 → 0 +0 −11 Original line number Diff line number Diff line import logging from openflexure_microscope.microscope import Microscope default_microscope = Microscope() # Restore loaded capture array to camera object logging.debug("Restoring captures...") default_microscope.captures.rebuild_captures() logging.debug("Microscope successfully attached!")