zooui.tilesystem.tilestore.tilestore module¶
Module for managing the disk-based tile storage facility.
- zooui.tilesystem.tilestore.tilestore._get_logger()[source]¶
- Function :
_get_logger()
- Parameters :
None
_get_logger() –> logging.Logger
Check if there’s a __logger instance for the TileStore module if not creates a logger instance for the TileStore module.
- zooui.tilesystem.tilestore.tilestore.get_media_path(media_id)[source]¶
- Function :
get_media_path(media_id)
- Parameters :
media_id : str
get_media_path(media_id) –> str
Return the path to the directory containing the tiles for the media identified by media_id.
- zooui.tilesystem.tilestore.tilestore.get_tile_path(tile_id, mkdirp=False, prefix=None, filext=None)[source]¶
- Function :
get_tile_path(tile_id, mkdirp, prefix, filext)
- Parameters :
tile_id : Tuple[str, int, int, int] mkdirp : bool prefix : Optional[str] filext : Optional[str]
get_tile_path(tile_id, mkdirp, prefix, filext) –> str
Return the path to the tile identified by tile_id.
If mkdirp is True, then any non-existent parent directories of the tile will be created.
If prefix is omitted, it will be set to the value returned by
get_media_path().If filext is omitted, it will be set to the value returned by
get_metadata().Note: Precondition - if filext is None, then the metadata file for the media that this tile belongs to exists and contains an entry for filext.
- zooui.tilesystem.tilestore.tilestore.load_metadata(media_id)[source]¶
- Function :
load_metadata(media_id)
- Parameters :
media_id : str
load_metadata(media_id) –> bool
Load metadata from disk for the given media_id, and return a bool indicating whether the load was successful.
- zooui.tilesystem.tilestore.tilestore.get_metadata(media_id, key)[source]¶
- Function :
get_metadata(media_id, key)
- Parameters :
media_id : str key : str
get_metadata(media_id, key) –> Optional[Any]
Return the value associated with the given metadata key, None if there is no such value.
- zooui.tilesystem.tilestore.tilestore.write_metadata(media_id, **kwargs)[source]¶
- Function :
write_metadata(media_id, **kwargs)
- Parameters :
media_id : str **kwargs : Any
write_metadata(media_id, **kwargs) –> None
Write the metadata given in kwargs for the given media_id.
- zooui.tilesystem.tilestore.tilestore.tiled(media_id)[source]¶
- Function :
tiled(media_id)
- Parameters :
media_id : str
tiled(media_id) –> bool
Return True iff the media identified by media_id has been tiled i.e. iff both a metadata file and the (0,0,0) tile exist.
- zooui.tilesystem.tilestore.tilestore.get_directory_size(path)[source]¶
- Function :
get_directory_size(path)
- Parameters :
path : str
get_directory_size(path) –> int
Calculate total size of a directory in bytes.
- zooui.tilesystem.tilestore.tilestore.get_tilestore_stats()[source]¶
- Function :
get_tilestore_stats()
- Parameters :
None
get_tilestore_stats() –> Dict[str, Any]
Get statistics about the tilestore directory.
Returns dictionary containing stats (total_size, file_count, media_count, total_size_mb).
- zooui.tilesystem.tilestore.tilestore.cleanup_old_tiles(max_age_days=3, dry_run=False)[source]¶
- Function :
cleanup_old_tiles(max_age_days, dry_run)
- Parameters :
max_age_days : int dry_run : bool
cleanup_old_tiles(max_age_days, dry_run) –> Dict[str, Any]
Clean up tile files that haven’t been accessed in more than max_age_days.
This function removes media directories whose files haven’t been accessed (read or written) in more than the specified number of days.
- Returns dictionary with cleanup statistics:
deleted_media_count: Number of media directories deleted
deleted_size_mb: Total size freed in MB
kept_media_count: Number of media directories kept
errors: List of error messages
- zooui.tilesystem.tilestore.tilestore.auto_cleanup(max_age_days=3, enable=True, collect_stats=True)[source]¶
- Function :
auto_cleanup(max_age_days, enable, collect_stats)
- Parameters :
- max_age_daysint
Maximum age in days for tiles (default: 3)
- enablebool
Enable automatic cleanup (default: True)
- collect_statsbool
Collect detailed before/after cleanup statistics (default: True)
Setting to False improves performance on large tilestores
auto_cleanup(max_age_days, enable, collect_stats) –> Optional[Dict[str, Any]]
Automatically clean up old tiles if enabled.
This function is designed to be called on startup or periodically. Returns cleanup statistics or None if disabled.