]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
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 | |
7c673cae | 7 | |
11fdf7f2 | 8 | import os |
f67539c2 | 9 | |
f6b5b4d7 TL |
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) | |
11fdf7f2 TL |
19 | |
20 | if 'UNITTEST' not in os.environ: | |
11fdf7f2 TL |
21 | class _ModuleProxy(object): |
22 | def __init__(self): | |
23 | self._mgr = None | |
24 | ||
25 | def init(self, module_inst): | |
11fdf7f2 | 26 | self._mgr = module_inst |
11fdf7f2 TL |
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() | |
11fdf7f2 | 34 | |
11fdf7f2 TL |
35 | else: |
36 | import logging | |
37 | logging.basicConfig(level=logging.DEBUG) | |
11fdf7f2 TL |
38 | logging.root.handlers[0].setLevel(logging.DEBUG) |
39 | os.environ['PATH'] = '{}:{}'.format(os.path.abspath('../../../../build/bin'), | |
40 | os.environ['PATH']) | |
f67539c2 | 41 | import sys |
11fdf7f2 | 42 | |
f67539c2 TL |
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 | |
11fdf7f2 TL |
48 | |
49 | mgr = mock.Mock() | |
eafe8130 | 50 | mgr.get_frontend_path.side_effect = lambda: os.path.abspath("./frontend/dist") |
e306af50 | 51 | |
e306af50 TL |
52 | # DO NOT REMOVE: required for ceph-mgr to load a module |
53 | from .module import Module, StandbyModule # noqa: F401 |