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