def setup_apps(reset=False): """ """ from ApplicationsRepository import ApplicationsRepository if reset: ApplicationsRepository.reset() sm_request_manager = SMRequestManager() webapps_dom = sm_request_manager.get_webapps() if webapps_dom == None: return True for webapp_dom in webapps_dom.childNodes: config_nodes = webapp_dom.getElementsByTagName('configuration') if len(config_nodes) < 1: continue config = json.loads(config_nodes[0].firstChild.data) if config.keys() < 1: continue app_id = webapp_dom.getAttribute('id') app_name = config.keys()[0] try: app_id = System.local_encode(app_id) app_name = System.local_encode(app_name) appl = setup_app(config, app_id, app_name, Config.mode) except: Logger.exception( "Setting up an application failed. Correct its configuration.") continue if appl is None: continue ApplicationsRepository.register(appl) Logger.info("Configured %s webapp(s)" % len(ApplicationsRepository.list())) return True