admin.py 598 B

123456789101112131415161718192021222324252627
  1. import logging
  2. from lakesuperior.env import env
  3. from lakesuperior.store.ldp_rs.lmdb_store import TxnManager
  4. __doc__ = '''
  5. Admin API.
  6. This module contains maintenance utilities and stats.
  7. '''
  8. logger = logging.getLogger(__name__)
  9. app_globals = env.app_globals
  10. def stats():
  11. '''
  12. Get repository statistics.
  13. @return dict Store statistics, resource statistics.
  14. '''
  15. repo_stats = {'rsrc_stats': env.app_globals.rdfly.count_rsrc()}
  16. with TxnManager(env.app_globals.rdf_store) as txn:
  17. repo_stats['store_stats'] = env.app_globals.rdf_store.stats()
  18. return repo_stats