def run(): print base = raw_input('Base file, eg. config/templates/wl_as_template.properties? ') env = raw_input('Environment, eg. local? ') print new_cfg = 'config/' + env + '/new_config.properties' input = BufferedReader(FileReader(base)) output = BufferedWriter(FileWriter(new_cfg)) output.write('base=' + base + '\n\n') line = input.readLine() while line is not None: if re.match('.*\?', line): output.write(line) output.newLine() line = input.readLine() input.close() output.close() log.info('new configuration file written to: ' + new_cfg)
def actionPerformed(self,actionEvent): self.scl_long_tuneup_controller.getMessageTextField().setText("") fc = JFileChooser(constants_lib.const_path_dict["LINAC_WIZARD_FILES_DIR_PATH"]) fc.setDialogTitle("Save SCL Table data into ASCII file") fc.setApproveButtonText("Save") fl_filter = FileNameExtensionFilter("ASCII *.dat File",["dat",]) fc.setFileFilter(fl_filter) returnVal = fc.showOpenDialog(self.scl_long_tuneup_controller.linac_wizard_document.linac_wizard_window.frame) if(returnVal == JFileChooser.APPROVE_OPTION): fl_out = fc.getSelectedFile() fl_path = fl_out.getPath() if(fl_path.rfind(".dat") != (len(fl_path) - 4)): fl_out = File(fl_out.getPath()+".dat") buffer_out = BufferedWriter(FileWriter(fl_out)) txt = "# cav pos cav_amp_epics cav_amp_model cav_phase rf_gap_avg_phase" txt += " phase_offset real_offset eKin_in eKin_out " txt += " delta_eKin_in_out_keV bpm_eKin_out model_eKin_out delta_eKin_fit_keV E0TL_MeV" buffer_out.write(txt) buffer_out.newLine() buffer_out.flush() cav_wrappers = self.scl_long_tuneup_controller.cav_wrappers for cav_ind in range(len(cav_wrappers)): cav_wrapper = cav_wrappers[cav_ind] txt = str(cav_ind+1)+" " txt += cav_wrapper.cav.getId()+" %8.3f "%cav_wrapper.pos+" %12.5g "%cav_wrapper.initLiveAmp txt += " %12.5g "%cav_wrapper.designAmp + " %8.3f "%cav_wrapper.designPhase txt += " %8.3f "%cav_wrapper.avg_gap_phase + " %8.3f "%cav_wrapper.scanPhaseShift txt += " %8.3f "%cav_wrapper.real_scanPhaseShift txt += " %12.5g "%cav_wrapper.eKin_in + " %12.5g "%cav_wrapper.eKin_out dE = 0. if(cav_ind != 0): dE = (cav_wrapper.eKin_in - cav_wrappers[cav_ind-1].eKin_out)*1000. txt += " %12.5g "%dE + " %12.5g "%cav_wrapper.bpm_eKin_out+ " %12.5g "%cav_wrapper.model_eKin_out txt += "% 6.1f"%(1000.*cav_wrapper.eKin_err) E0TL = 0. if(len(cav_wrapper.energy_guess_harm_funcion.getParamArr()) > 1): E0TL = cav_wrapper.energy_guess_harm_funcion.getParamArr()[1] txt += " %12.5g "%E0TL buffer_out.write(txt) buffer_out.newLine() #---- end of writing buffer_out.flush() buffer_out.close()
securityDir = File(domainPath + File.separator + domainName + File.separator + 'servers' + File.separator + str(serverName) + File.separator + 'security') if not securityDir.exists() and rootDir is None: log.info('Creating directory ' + str(securityDir)) securityDir.mkdirs() bootFile = File(securityDir.getAbsolutePath() + File.separator + 'boot.properties') # TODO: Use flag no.managed.server.boot.properties=true/false instead of checking domain called osb_domain (H@CK) if not bootFile.exists() and rootDir is None and not domainName == 'osb_domain': log.info('Creating boot.properties for server [' + str(serverName) + '].') bootFile.createNewFile() fileWriter = FileWriter(bootFile) bufWriter = BufferedWriter(fileWriter) bufWriter.write('username='******'password='******'Ignoring boot.properties creation for [' + str(serverName) + '].') #======================================================================================= # Configure additional managed server properties #======================================================================================= __configureAdditionalManagedServerProperties(serverName, enableHostnameVerification) __configureCoherenceManagedServerProperties(serverName,coherenceUnicastAddress,wlsVersion) servergroups=configProperties.getProperty('wls.server.'+str(server)+'.servergroups') if servergroups is not None: servergroupslist=servergroups.split(',') if servergroupslist is not None and len(servergroupslist)>0: __configureServerGroups(serverName,servergroupslist,wlsVersion)
# Write the domain #======================================================================================= try: log.info('Writing domain') writeDomain(str(domainPath) + '/' + str(domainName)) securityDir = File(domainPath + File.separator + domainName + File.separator + 'servers' + File.separator + str(adminServerName) + File.separator + 'security') if not securityDir.exists(): securityDir.mkdirs() bootFile = File(securityDir.getAbsolutePath() + File.separator + 'boot.properties') bootFile.createNewFile() fileWriter = FileWriter(bootFile) bufWriter = BufferedWriter(fileWriter) bufWriter.write('username='******'password='******'Unable to write domain [' + str(domainPath) + '/' + str(domainName) + '] : ' + str(error) #======================================================================================= # Close the domain template. #======================================================================================= closeTemplate() #============================================================================== # __addTemplate # # Loops through and adds all configured templates to domain, calling 'addTemplate'