def start_app(self, appdef=None, config=None): """ @brief Start an app from an app definition. Note: apps can come in one of 2 variants: 1 processapp: In-line defined process to be started 2 regular app: Full app definition """ log.debug("AppManager.start_app(appdef=%s) ..." % appdef) appdef = DotDict(appdef) app_config = DictModifier(CFG) if 'config' in appdef: # Apply config from app file app_file_cfg = DotDict(appdef.config) app_config.update(app_file_cfg) if config: # Nest dict modifier and apply config from rel file app_config = DictModifier(app_config, config) if 'processapp' in appdef: # Case 1: Appdef contains definition of process to start name, module, cls = appdef.processapp try: pid = self.container.spawn_process(name, module, cls, app_config) appdef._pid = pid self.apps.append(appdef) except Exception, ex: log.exception("Appl %s start from processapp failed" % appdef.name)
def test_dict_modifier(self): base = DotDict({"foo": "bar", "bah": "fah"}) dict_modifier = DictModifier(base) self.assertEqual(dict_modifier["foo"], "bar") top = DotDict({"bah": "lah", "doh": "ray"}) dict_modifier.update(top) saved_dict_modifier = dict_modifier self.assertEqual(dict_modifier["foo"], "bar") self.assertEqual(dict_modifier["bah"], "lah") self.assertEqual(dict_modifier["doh"], "ray") dict_modifier = DictModifier(dict_modifier) self.assertEqual(dict_modifier["foo"], "bar") self.assertEqual(dict_modifier["bah"], "lah") self.assertEqual(dict_modifier["doh"], "ray") self.assertEqual(dict_modifier.base, saved_dict_modifier) top = DotDict({"bah": "trah"}) dict_modifier.update(top) saved_dict_modifier = dict_modifier self.assertEqual(dict_modifier["foo"], "bar") self.assertEqual(dict_modifier["bah"], "trah") self.assertEqual(dict_modifier["doh"], "ray")