Esempio n. 1
0
 def sync(self, path=""):
     if not path:
         try: path = self._path
         except AttributeError: pass
     if not path: path = self._path = j(dopath(self), rtime())
     logging.warn("! sync %s" % path)
     d, fn = os.path.split(path)
     cdir(d)
     todisk = self.prepare()
     datafile = open(os.path.abspath(path) + ".tmp", 'w')
     fcntl.flock(datafile, fcntl.LOCK_EX | fcntl.LOCK_NB)
     datafile.write(headertxt % "%s characters" % len(todisk))
     datafile.write(todisk)
     datafile.write("\n")
     fcntl.flock(datafile, fcntl.LOCK_UN)
     datafile.close()
     os.rename(path + ".tmp", path)
     return path
Esempio n. 2
0
 def save(self, stime=""):
     if not stime: stime = rtime()
     path = j(dopath(self), stime)
     self.sync(path)
     return stime