Loading openflexure_microscope/__init__.py +1 −2 Original line number Diff line number Diff line __all__ = ["Microscope", "config", "task", "utilities"] __all__ = ["Microscope", "config", "utilities"] __version__ = "0.1.0" from .microscope import Microscope from . import config from . import utilities from . import task from . import common openflexure_microscope/camera/pi.py +0 −3 Original line number Diff line number Diff line Loading @@ -317,9 +317,6 @@ class PiCameraStreamer(BaseCamera): """ Change the camera zoom, handling re-centering and scaling. """ logging.warning( "set_zoom is deprecated. Please use the 'zoom' property in picamera_settings." ) with self.lock: self.status["zoom_value"] = float(zoom_value) if self.status["zoom_value"] < 1: Loading openflexure_microscope/common/labthings/find.py +18 −1 Original line number Diff line number Diff line import logging from flask import current_app from . import EXTENSION_NAME def _current_labthing(): app = current_app app = current_app._get_current_object() if not app: return None logging.debug("Active app extensions:") logging.debug(app.extensions) logging.debug("Active labthing:") logging.debug(app.extensions[EXTENSION_NAME]) return app.extensions[EXTENSION_NAME] Loading @@ -30,3 +35,15 @@ def find_device(device_name, labthing_instance=None): return labthing_instance.devices[device_name] else: return None def find_plugin(plugin_name, labthing_instance=None): if not labthing_instance: labthing_instance = _current_labthing() logging.debug("Current labthing:") logging.debug(_current_labthing()) if plugin_name in labthing_instance.plugins: return labthing_instance.plugins[plugin_name] else: return None openflexure_microscope/common/labthings/labthing.py +8 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,14 @@ class LabThing(object): # TODO: Add plugin routes for plugin_view_id, plugin_view in plugin_object.views.items(): # Add route to the plugins blueprint self.add_resource( plugin_view["view"], "/plugins" + plugin_view["rule"], **plugin_view["kwargs"], ) ### Resource stuff def _complete_url(self, url_part, registration_prefix): Loading openflexure_microscope/common/labthings/plugins.py +9 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ class BasePlugin: self.name = name self.methods = {} @property def views(self): return self._views Loading Loading @@ -102,6 +104,13 @@ class BasePlugin: def _name_uri_safe(self): return snake_to_spine(self._name_python_safe) def add_method(self, method_name, method): self.methods[method_name] = method if not hasattr(self, method_name): setattr(self, method_name, method) else: logging.warning("Unable to bind method to plugin. Method name already exists.") def find_plugins(plugin_path, module_name="plugins"): print(f"Loading plugins from {plugin_path}") Loading Loading
openflexure_microscope/__init__.py +1 −2 Original line number Diff line number Diff line __all__ = ["Microscope", "config", "task", "utilities"] __all__ = ["Microscope", "config", "utilities"] __version__ = "0.1.0" from .microscope import Microscope from . import config from . import utilities from . import task from . import common
openflexure_microscope/camera/pi.py +0 −3 Original line number Diff line number Diff line Loading @@ -317,9 +317,6 @@ class PiCameraStreamer(BaseCamera): """ Change the camera zoom, handling re-centering and scaling. """ logging.warning( "set_zoom is deprecated. Please use the 'zoom' property in picamera_settings." ) with self.lock: self.status["zoom_value"] = float(zoom_value) if self.status["zoom_value"] < 1: Loading
openflexure_microscope/common/labthings/find.py +18 −1 Original line number Diff line number Diff line import logging from flask import current_app from . import EXTENSION_NAME def _current_labthing(): app = current_app app = current_app._get_current_object() if not app: return None logging.debug("Active app extensions:") logging.debug(app.extensions) logging.debug("Active labthing:") logging.debug(app.extensions[EXTENSION_NAME]) return app.extensions[EXTENSION_NAME] Loading @@ -30,3 +35,15 @@ def find_device(device_name, labthing_instance=None): return labthing_instance.devices[device_name] else: return None def find_plugin(plugin_name, labthing_instance=None): if not labthing_instance: labthing_instance = _current_labthing() logging.debug("Current labthing:") logging.debug(_current_labthing()) if plugin_name in labthing_instance.plugins: return labthing_instance.plugins[plugin_name] else: return None
openflexure_microscope/common/labthings/labthing.py +8 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,14 @@ class LabThing(object): # TODO: Add plugin routes for plugin_view_id, plugin_view in plugin_object.views.items(): # Add route to the plugins blueprint self.add_resource( plugin_view["view"], "/plugins" + plugin_view["rule"], **plugin_view["kwargs"], ) ### Resource stuff def _complete_url(self, url_part, registration_prefix): Loading
openflexure_microscope/common/labthings/plugins.py +9 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ class BasePlugin: self.name = name self.methods = {} @property def views(self): return self._views Loading Loading @@ -102,6 +104,13 @@ class BasePlugin: def _name_uri_safe(self): return snake_to_spine(self._name_python_safe) def add_method(self, method_name, method): self.methods[method_name] = method if not hasattr(self, method_name): setattr(self, method_name, method) else: logging.warning("Unable to bind method to plugin. Method name already exists.") def find_plugins(plugin_path, module_name="plugins"): print(f"Loading plugins from {plugin_path}") Loading