def save_setup(self,slot,tag,desc,make_default): self.savcond.acquire() try: if self.quitting: return else: self.saving = True finally: self.savcond.release() filename = agentd.user_setup_file(slot,tag) filenamesave = filename+"~" def done(*args,**kwds): agentd.delete_user_slot(slot) os.rename(filenamesave,filename) if make_default: agentd.set_default_setup(filename) self.setups_changed(filename) self.savcond.acquire() try: self.saving = False self.savcond.notify() finally: self.savcond.release() print 'save complete',filename self.info_dialog('Setup Saved','Setup Saved',"The user setup '"+slot+"' was successfully saved") r = self.run_background(self.agent.save_file,filenamesave,desc) r.setCallback(done,r).setErrback(done,r) return filename
def edit_setup(self,orig,slot,tag,desc): self.savcond.acquire() try: if self.quitting: return else: self.saving = True finally: self.savcond.release() filename = agentd.user_setup_file(slot,tag) self.agent.edit_file(orig,filename,desc) self.setups_changed(filename) self.savcond.acquire() try: self.saving = False self.savcond.notify() finally: self.savcond.release() print 'editing complete',filename self.info_dialog('Setup Edited','Setup Edited',"The user setup '"+slot+"' was successfully edited") return filename
def edit_setup(self, orig, slot, tag, desc): self.savcond.acquire() try: if self.quitting: return else: self.saving = True finally: self.savcond.release() path = agentd.user_setup_file(slot, tag) if orig != path: orig_d = os.path.dirname(orig) orig_f = os.path.basename(orig) path_d = os.path.dirname(path) path_f = os.path.basename(path) for f in resource.os_listdir(orig_d): if f.startswith(orig_f): f2 = os.path.join(path_d, path_f + f[len(orig_f):]) resource.os_rename(os.path.join(orig_d, f), f2) database = state.open_database(path, True) trunk = database.get_trunk() upgrade.set_description(trunk, desc) trunk.save(piw.tsd_time(), '') database.flush() self.setups_changed(path) self.savcond.acquire() try: self.saving = False self.savcond.notify() finally: self.savcond.release() print 'editing complete', path self.info_dialog( 'Setup Edited', 'Setup Edited', "The user setup '" + slot + "' was successfully edited") return path