def getSetConfig(question, section, option, reader=getWithDefault): value = CONFIG.get(section, option) if CONFIG.isTrue("global", "accept_defaults"): putMessage(question + " : using <" + value + ">") return value new_value = reader(question, value) CONFIG.set(section, option, new_value) return new_value
def configure(self): # asks all the questions for question, section, option, dic in self.options: if "when" in dic: wsec, wopt = dic["when"] if not CONFIG.isTrue(wsec, wopt): continue if "unless" in dic: usec, uopt = dic["unless"] if CONFIG.isTrue(usec, uopt): continue gstype = None if "type" in dic: gstype = dic["type"] utils.getSetConfigType(question, section, option, gstype) self.postConfigure() # save the answers CONFIG.writeIni()
def configureProperties(self): for filename, dic in self.properties_options: utils.configurePropertiesWebApp(self.pretty_name, filename, self.section_name, dic) if self.properties_options: if CONFIG.isTrue("tomcat", "use_manager"): utils.putWait("Reloading " + self.pretty_name) utils.manageTomcat("reload?path=/" + self.cget("name")) else: utils.stopTomcat() utils.startTomcat() self.postConfigureProperties()
def deployWar(pretty_name, section_name): webapp_name = CONFIG.get(section_name, "name") if CONFIG.isTrue("tomcat", "use_manager"): putWait("Deploying " + pretty_name) manageTomcat("deploy?path=/" + webapp_name + "&update=true&war=file://" + sh_pwd() + "/" + CONFIG.get(section_name, "repo")) else: putMessage("Deploying " + pretty_name + " ...") stopTomcat() copyWar(CONFIG.get(section_name, "repo"), webapp_name) startTomcat()
def deployWarDB(pretty_name, section_name): webapp_name = CONFIG.get(section_name, "name") contextfile = configureDB(pretty_name, webapp_name, section_name) if CONFIG.isTrue("tomcat", "use_manager"): putWait("Deploying " + pretty_name) pwd = sh_pwd() + "/" manageTomcat("deploy?path=/" + webapp_name + "&update=true&config=file://" + pwd + contextfile + "&war=file://" + pwd + CONFIG.get(section_name, "repo")) else: putMessage("Deploying " + pretty_name + " ...") stopTomcat() host_contextfile = (CONFIG.get("tomcat", "catalina_home") + "conf/Catalina/localhost/" + webapp_name + ".xml") copyWar(CONFIG.get(section_name, "repo"), webapp_name, host_contextfile) webapp_contextfile = (CONFIG.get("tomcat", "catalina_home") + webapp_name + "/META-INF/context.xml") sh_cp(contextfile, webapp_contextfile) sh_cp(contextfile, host_contextfile) startTomcat()
def cisTrue(self, option_name): return CONFIG.isTrue(self.section_name, option_name)