def _release_lock(self): try: os.unlink(self.lockname) except OSError, err: if err.errno == 2: # No such file or directory msger.warning("lock file(%s) should be there, " "but it doesn't exist" % self.lockname) else: raise
def _thread(): while 1: if to_die.wait(interval): break #FIXME: eliminate the message print out every interval make_report(local_path) if rsync(local_path, remote_path) != 0: msger.warning('sync thread exit, please sync manually') break msger.info('sync thread exit')
def rsync(local_path, remote_path): cmd = "rsync -a '%s/'* '%s'" % (local_path, remote_path) msger.debug(cmd) ret = os.system(cmd) if ret == 0: return 0 msger.warning('sync to %s failed, time a few seconds and retry') time.sleep(5) ret = os.system(cmd) if ret == 0: return 0 msger.warning('sync to %s failed, please check the network') return ret