Added base plugin resource
This commit is contained in:
parent
469e8218e0
commit
2b5b0b8744
8 changed files with 299 additions and 60 deletions
32
openflexure_microscope/common/labthings/find.py
Normal file
32
openflexure_microscope/common/labthings/find.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from flask import current_app
|
||||
|
||||
from . import EXTENSION_NAME
|
||||
|
||||
|
||||
def _current_labthing():
|
||||
app = current_app
|
||||
if not app:
|
||||
return None
|
||||
return app.extensions[EXTENSION_NAME]
|
||||
|
||||
|
||||
def registered_plugins(labthing_instance=None):
|
||||
if not labthing_instance:
|
||||
labthing_instance = _current_labthing()
|
||||
return labthing_instance.plugins
|
||||
|
||||
|
||||
def registered_devices(labthing_instance=None):
|
||||
if not labthing_instance:
|
||||
labthing_instance = _current_labthing()
|
||||
return labthing_instance.devices
|
||||
|
||||
|
||||
def find_device(device_name, labthing_instance=None):
|
||||
if not labthing_instance:
|
||||
labthing_instance = _current_labthing()
|
||||
|
||||
if device_name in labthing_instance.devices:
|
||||
return labthing_instance.devices[device_name]
|
||||
else:
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue