def _save_to_disk(self): if self.valstr is not None: log.msg("%s._save_to_disk(): fname: %s" % ( self.objname, self.fname, )) of = open(self.fname + ".tmp", "wb") of.write(self.valstr) of.flush() of.close() of = None fileutil.remove_if_possible(self.fname) fileutil.rename(self.fname + ".tmp", self.fname) log.msg( "%s._save_to_disk(): now, having finished write(), os.path.isfile(%s): %s" % ( self, self.fname, os.path.isfile(self.fname), )) self.valstr = None self.dirty = False try: self.savertask.callId.cancel() except: pass self.savertask = None
def writekeys(slice, keys): import fileutil, tempfile keysfile = os.path.expanduser("~%s/.ssh/authorized_keys" % slice) temp = tempfile.mktemp() f = open(temp, "w") for k in keys: f.write(k + "\n") f.close() fileutil.rename(temp, keysfile)
def _save_to_disk(self): if self.valstr is not None: log.msg("%s._save_to_disk(): fname: %s" % (self.objname, self.fname,)) of = open(self.fname + ".tmp", "wb") of.write(self.valstr) of.flush() of.close() of = None fileutil.remove_if_possible(self.fname) fileutil.rename(self.fname + ".tmp", self.fname) log.msg("%s._save_to_disk(): now, having finished write(), os.path.isfile(%s): %s" % (self, self.fname, os.path.isfile(self.fname),)) self.valstr = None self.dirty = False try: self.savertask.callId.cancel() except: pass self.savertask = None
def renameleases(self, leasesdir, vmsdir, ips): for ip in ips: oldfile = leasesdir + "/" + ip newfile = vmsdir + "/" + ip fileutil.rename(oldfile, newfile)