void ActivePyModule::config_notify()
{
+ if (is_dead()) {
+ dout(5) << "cancelling config_notify" << dendl;
+ return;
+ }
+
Gil gil(py_module->pMyThreadState, true);
- dout(20) << "Calling " << py_module->get_name() << ".config_notify..."
+ dout(20) << "Calling " << py_module->get_name() << "._config_notify..."
<< dendl;
auto remoteResult = PyObject_CallMethod(pClassInstance,
- const_cast<char*>("config_notify"),
+ const_cast<char*>("_config_notify"),
(char*)NULL);
if (remoteResult != nullptr) {
Py_DECREF(remoteResult);
derr << "Failed to invoke shutdown() on " << get_name() << dendl;
derr << handle_pyerror() << dendl;
}
+
+ dead = true;
}
- void PyModuleRunner::log(int level, const std::string &record)
+ void PyModuleRunner::log(const std::string &record)
{
#undef dout_prefix
- #define dout_prefix *_dout << "mgr[" << get_name() << "] "
- dout(ceph::dout::need_dynamic(level)) << record << dendl;
+ #define dout_prefix *_dout
+ dout(0) << record << dendl;
#undef dout_prefix
#define dout_prefix *_dout << "mgr " << __func__ << " "
}
from cherrypy.lib.static import serve_file
from . import Controller, UiApiController, BaseController, Proxy, Endpoint
- from .. import mgr, logger
+ from .. import mgr
+
+
+ logger = logging.getLogger("controllers.home")
-LANGUAGES = {f for f in os.listdir(mgr.get_frontend_path())
- if os.path.isdir(os.path.join(mgr.get_frontend_path(), f))}
-LANGUAGES_PATH_MAP = {f.lower(): {'lang': f, 'path': os.path.join(mgr.get_frontend_path(), f)}
- for f in LANGUAGES}
-# pre-populating with the primary language subtag
-for _lang in list(LANGUAGES_PATH_MAP.keys()):
- if '-' in _lang:
- LANGUAGES_PATH_MAP[_lang.split('-')[0]] = {
- 'lang': LANGUAGES_PATH_MAP[_lang]['lang'], 'path': LANGUAGES_PATH_MAP[_lang]['path']}
-
-
-def _get_default_language():
- with open("{}/../package.json".format(mgr.get_frontend_path()), "r") as f:
- config = json.load(f)
- return config['config']['locale']
-
-
-DEFAULT_LANGUAGE = _get_default_language()
-DEFAULT_LANGUAGE_PATH = os.path.join(mgr.get_frontend_path(), DEFAULT_LANGUAGE)
+class LanguageMixin(object):
+ def __init__(self):
+ self.LANGUAGES = {
+ f
+ for f in os.listdir(mgr.get_frontend_path())
+ if os.path.isdir(os.path.join(mgr.get_frontend_path(), f))
+ }
+ self.LANGUAGES_PATH_MAP = {
+ f.lower(): {
+ 'lang': f,
+ 'path': os.path.join(mgr.get_frontend_path(), f)
+ }
+ for f in self.LANGUAGES
+ }
+ # pre-populating with the primary language subtag.
+ for lang in list(self.LANGUAGES_PATH_MAP.keys()):
+ if '-' in lang:
+ self.LANGUAGES_PATH_MAP[lang.split('-')[0]] = {
+ 'lang': self.LANGUAGES_PATH_MAP[lang]['lang'],
+ 'path': self.LANGUAGES_PATH_MAP[lang]['path']
+ }
+ with open("{}/../package.json".format(mgr.get_frontend_path()),
+ "r") as f:
+ config = json.load(f)
+ self.DEFAULT_LANGUAGE = config['config']['locale']
+ self.DEFAULT_LANGUAGE_PATH = os.path.join(mgr.get_frontend_path(),
+ self.DEFAULT_LANGUAGE)
+ super(LanguageMixin, self).__init__()
@Controller("/", secure=False)