]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/__init__.py
import ceph 16.2.7
[ceph.git] / ceph / src / pybind / mgr / dashboard / __init__.py
1 # -*- coding: utf-8 -*-
2 # pylint: disable=wrong-import-position,global-statement,protected-access
3 """
4 ceph dashboard module
5 """
6 from __future__ import absolute_import
7
8 import os
9
10 import cherrypy
11
12 if 'COVERAGE_ENABLED' in os.environ:
13 import coverage # pylint: disable=import-error
14 __cov = coverage.Coverage(config_file="{}/.coveragerc".format(os.path.dirname(__file__)),
15 data_suffix=True)
16 __cov.start()
17 cherrypy.engine.subscribe('after_request', __cov.save)
18 cherrypy.engine.subscribe('stop', __cov.stop)
19
20 if 'UNITTEST' not in os.environ:
21 class _ModuleProxy(object):
22 def __init__(self):
23 self._mgr = None
24
25 def init(self, module_inst):
26 self._mgr = module_inst
27
28 def __getattr__(self, item):
29 if self._mgr is None:
30 raise AttributeError("global manager module instance not initialized")
31 return getattr(self._mgr, item)
32
33 mgr = _ModuleProxy()
34
35 else:
36 import logging
37 logging.basicConfig(level=logging.DEBUG)
38 logging.root.handlers[0].setLevel(logging.DEBUG)
39 os.environ['PATH'] = '{}:{}'.format(os.path.abspath('../../../../build/bin'),
40 os.environ['PATH'])
41 import sys
42
43 # Used to allow the running of a tox-based yml doc generator from the dashboard directory
44 if os.path.abspath(sys.path[0]) == os.getcwd():
45 sys.path.pop(0)
46
47 from tests import mock # type: ignore
48
49 mgr = mock.Mock()
50 mgr.get_frontend_path.side_effect = lambda: os.path.abspath("./frontend/dist")
51
52 # DO NOT REMOVE: required for ceph-mgr to load a module
53 from .module import Module, StandbyModule # noqa: F401