class OFMGalleryDBEngine(ABC): (source)
Known subclasses: openflexure_microscope_server.scan_directories.ScanGalleryDBEngine, openflexure_microscope_server.things.camera.CameraGalleryDBEngine, openflexure_microscope_server.things.timelapse.TimelapseGalleryDBEngine
Constructor: OFMGalleryDBEngine(data_dir, thing)
A database engine that can be subclassed for different Gallery providers.
| Method | __init__ |
Initialise the database engine. |
| Method | add |
Add an item to the gallery database. |
| Method | delete |
Delete an item from the gallery database. |
| Method | dispose |
Dispose of the active connections for this database engine. |
| Method | entry |
Convert GalleryEntry to GalleryEntryModel. |
| Method | fullpath |
Convert the abs native path to the relative posix path for the database. |
| Method | get |
Get a single item from the gallery database. |
| Method | get |
Get a list of all Gallery Entries. |
| Method | get |
Get a list of entries as a base model for the API. |
| Method | get |
Get a list of the paths for all gallery items. |
| Method | normpath |
Convert the relative posix path from the database to the abs native path. |
| Method | rebuild |
Rebuild a single gallery entry as it has changed on disk. |
| Method | session |
Yield a database session. Commit on completion, rollback on error. |
| Method | sync |
Sync the database with the file system. |
| Class Variable | card |
Undocumented |
| Class Variable | gallery |
Undocumented |
| Method | _card |
Create the action buttons for this entry's card. |
| Method | _card |
Create the messages for this entry's card. |
| Method | _create |
Create the viewer data for the GalleryEntryModel. |
| Method | _delete |
Return the endpoint for deleting an entry (relative to the base URL). |
| Method | _download |
Create the download buttons for this entry. |
| Method | _generate |
Create a GalleryEntry for an item based on the data on disk. |
| Method | _hash |
Create a unique hash for an item. |
| Method | _list |
List all the items on this file system. |
| Method | _mounted |
Return the mount point for the normalised path. |
| Instance Variable | _data |
Undocumented |
| Instance Variable | _engine |
Undocumented |
| Instance Variable | _thing |
Undocumented |
Initialise the database engine.
| Parameters | |
datastr | The directory of the data. |
thing:lt.Thing | The thing that is managing this data source. |
Convert the abs native path to the relative posix path for the database.
The database requires normalised POSIX paths.
Get a single item from the gallery database.
| Parameters | |
path:str | The normalised relative posixpath for the requested entry. |
| Returns | |
GalleryEntry | None | The GalleryEntry that matches the path, or None if nothing matches. |
Sync the database with the file system.
This is run when the microscope first loads. It can also be manually called if the data is changed on disk. It shouldn't be needed in other situations.
Create the action buttons for this entry's card.
This is empty but this method can be overloaded to add other actions.
Create the messages for this entry's card.
This is empty but this method can be overloaded to add other actions.
openflexure_microscope_server.scan_directories.ScanGalleryDBEngine, openflexure_microscope_server.things.timelapse.TimelapseGalleryDBEngineCreate the viewer data for the GalleryEntryModel.
This always sends data to view the path as an image. This method can be overloaded to create other displays.
| Parameters | |
entry:GalleryEntry | The GalleryEntry from the database for this item. |
| Returns | |
ViewerData | None | Undocumented |
openflexure_microscope_server.scan_directories.ScanGalleryDBEngine, openflexure_microscope_server.things.camera.CameraGalleryDBEngine, openflexure_microscope_server.things.timelapse.TimelapseGalleryDBEngineReturn the endpoint for deleting an entry (relative to the base URL).
| Parameters | |
path:str | The normalised relative posixpath for the item. This is the primary key of the GalleryEntry table. |
| Returns | |
str | Undocumented |
openflexure_microscope_server.scan_directories.ScanGalleryDBEngine, openflexure_microscope_server.things.timelapse.TimelapseGalleryDBEngineCreate the download buttons for this entry.
This always sends one download button that points to the mounted path of the entry. This method can be overloaded to add other buttons or modify the button.
str, gallery_added_data: dict | None = None) -> GalleryEntry:
(source)
¶
openflexure_microscope_server.scan_directories.ScanGalleryDBEngine, openflexure_microscope_server.things.camera.CameraGalleryDBEngine, openflexure_microscope_server.things.timelapse.TimelapseGalleryDBEngineCreate a GalleryEntry for an item based on the data on disk.
| Parameters | |
path:str | The normalised relative posixpath for the item. This is the primary key of the GalleryEntry table. |
gallerydict | None | Any data added by the gallery. This can be used to persist gallery added data even if item is modified on disk. |
| Returns | |
GalleryEntry | A GalleryEntry for the item. |
openflexure_microscope_server.scan_directories.ScanGalleryDBEngine, openflexure_microscope_server.things.camera.CameraGalleryDBEngine, openflexure_microscope_server.things.timelapse.TimelapseGalleryDBEngineCreate a unique hash for an item.
For images in the gallery this is just checking the image has not been updated or replaced. For speed we use a blake2b 8-byte hash of the file size and the modified time.
| Parameters | |
path:str | The normalised relative posixpath for the item to hash. This is the primary key of the GalleryEntry table. |
| Returns | |
str | A unique identifier to check if the item has changed. For large items that are a folder of data it is not recommended to hash the entire file as this is slow. Instead, hash just enough information about the item to confirm that it's unchanged. |
openflexure_microscope_server.scan_directories.ScanGalleryDBEngine, openflexure_microscope_server.things.camera.CameraGalleryDBEngine, openflexure_microscope_server.things.timelapse.TimelapseGalleryDBEngineList all the items on this file system.
| Returns | |
list[ | A list of paths. |