def _save_profile(self, name): if self.profiles.has_section(name): if QMessageBox.warning( self, "Overwriting profile", """<P>Do you really want to overwrite the existing profile '%s'?</P>""" % name, QMessageBox.Ok | QMessageBox.Cancel, QMessageBox.Ok) != QMessageBox.Ok: return newprof = False else: self.profiles.add_section(name) newprof = True TDLOptions.save_to_config(self.profiles, name) try: ff = file(PROFILE_FILE, "wt") for section in sorted(self.profiles.sections()): ff.write("[%s]\n" % section) for opt, value in sorted(self.profiles.items(section)): ff.write("%s = %s\n" % (opt.lower(), value)) ff.write("\n") ff.close() except: dprintf(0, "error writing %s" % PROFILE_FILE) traceback.print_exc() QMessageBox.warning( self, "Error saving profile", """<P>There was an error writing to the %s file, profile was not saved.</P>""" % PROFILE_FILE) if newprof: self.emit(PYSIGNAL("refreshProfiles()"))
def _save_profile (self,name): if self.profiles.has_section(name): if QMessageBox.warning(self,"Overwriting profile","""<P>Do you really want to overwrite the existing profile '%s'?</P>"""%name, QMessageBox.Ok|QMessageBox.Cancel,QMessageBox.Ok) != QMessageBox.Ok: return; newprof = False; else: self.profiles.add_section(name); newprof = True; TDLOptions.save_to_config(self.profiles,name); try: ff = file(PROFILE_FILE,"wt"); for section in sorted(self.profiles.sections()): ff.write("[%s]\n"%section); for opt,value in sorted(self.profiles.items(section)): ff.write("%s = %s\n"%(opt.lower(),value)); ff.write("\n"); ff.close(); except: dprintf(0,"error writing %s"%PROFILE_FILE); traceback.print_exc(); QMessageBox.warning(self,"Error saving profile","""<P>There was an error writing to the %s file, profile was not saved.</P>"""%PROFILE_FILE); if newprof: self.emit(PYSIGNAL("refreshProfiles()"));
elif job_match: if not module: print( "### Error: please specify a script before any TDL jobs" ) raise RuntimeError("TDL job specified before script") job = job_match.group(1) if options.save_config: sect = savesect or (script and os.path.splitext( os.path.basename(script))[0]) or "default" print(("### Saving options to %s [%s]" % (saveconffile, sect))) if sect.lower() != "default" and not saveconf.has_section( sect): saveconf.add_section(sect) TDLOptions.save_to_config(saveconf, sect) saveconf.rewrite(saveconffile) print(("### Running TDL job \"%s\"" % job)) try: func = TDLOptions.get_job_func(job) except NameError: func = getattr(module, job, None) if not func: print( "### Error: no job such job found. Perhaps it is not available with this option set?" ) print("### Currently available jobs are:" "") for name, job_id in TDLOptions.get_all_jobs(): print(("### '%s' (id: %s)" % (name, job_id))) raise NameError("No such TDL job: '%s'" % job)
section = None; print "### (using previously set options)"; module,ns,msg = Compile.compile_file(mqs,script,config=section); print "### ",msg; elif job_match: if not module: print "### Error: please specify a script before any TDL jobs"; raise RuntimeError,"TDL job specified before script"; job = job_match.group(1); if options.save_config: sect = savesect or ( script and os.path.splitext(os.path.basename(script))[0] ) or "default" print "### Saving options to %s [%s]" % (saveconffile, sect) if sect.lower() != "default" and not saveconf.has_section(sect): saveconf.add_section(sect) TDLOptions.save_to_config(saveconf,sect) saveconf.rewrite(saveconffile) print "### Running TDL job \"%s\""%job; try: func = TDLOptions.get_job_func(job); except NameError: func = getattr(module,job,None); if not func: print "### Error: no job such job found. Perhaps it is not available with this option set?" print "### Currently available jobs are:"""; for name,job_id in TDLOptions.get_all_jobs(): print "### '%s' (id: %s)"%(name,job_id); raise NameError,"No such TDL job: '%s'"%job; try: sys.stdout.flush(); sys.stderr.flush();