示例#1
0
文件: object.py 项目: bthate/meds
 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
示例#2
0
文件: object.py 项目: bthate/meds
 def save(self, stime=""):
     if not stime: stime = rtime()
     path = j(dopath(self), stime)
     self.sync(path)
     return stime