def push(self, f_name, f_code): f = branchManager() f.set_path(f_code) try: os.makedirs(os.path.dirname(os.sep.join([self.path, f.get_abs_path("wav")]))) except Exception, e: pass
def _get_file_info(self, first, last, deliver): counter = branchManager() counter.set_path(first) if counter.get_code() != "000000": counter.increment() else: counter.set_code(self.code) scan_result = {} i = 0 self._log.write(self.__class__.__name__, "the duality first:%s, last:%s"%(counter.get_path(), last), "INFO") while counter.get_path() <= last: if i >= self.m_limit: deliver(scan_result) scan_result = {} i = 0 f = counter.get_path() w = os.sep.join([self.path,counter.get_abs_path("wav")]) x = os.sep.join([self.path,counter.get_abs_path("xml")]) if os.path.isfile(w) and os.path.isfile(x): tmp = os.stat(w) scan_result[f] = {} scan_result[f]["wav_size"] = tmp.st_size scan_result[f]["wav_time"] = tmp.st_ctime tmp = os.stat(x) scan_result[f]["xml_size"] = tmp.st_size #counter = str(int(counter)+1).zfill(15) # take it signed for historical reason counter.increment() i+=1 deliver(scan_result)
def _recheck(self): from base_settings import base_settings bs = base_settings() if self.last_seen == "None": return 0 last = self.last_seen b = branchManager() b.set_path(last) first = str(long(self.last_seen)-self.bc).zfill(15) if first < b.min(): first = b.get_path() self._log.write(self.__class__.__name__, "Starting Recheck %s, %s , %s"%(first, last, self.bc), "INFO") self._get_file_info(first, last, bs.send_revisited_records)
def run_sync(self): from base_settings import base_settings bs = base_settings() tmp = bs.dest.get_temp() if self.need_tmp: # definisce se serve effettivamente il file tmp if tmp == None: self._log.write("NEED TMP", "USE ORIGIN TMP", "INFO") else: tmp = None while 1: try: l = self.list_of_moves.pop(0) b = branchManager() b.set_path(l[1]) f = os.sep.join([self.path, b.get_abs_path()]) if tmp != None: self._log.write("NEED TMP", "Move to tmp", "INFO") f2 = os.sep.join([tmp, b.get_path()]) self.push(f, f2); f = f2 # sposto ed f diventa il percorso da tmp try: bs.dest.push(f, l[1]) self.list_of_moved.append(l[0]) if self.list_of_moved.__len__() > self.m_limit: tmp = self.list_of_moved self.list_of_moved = [] bs.send_ack(tmp) except: pass except IndexError, e: self.is_running = False tmp = self.list_of_moved self.list_of_moved = [] bs.send_ack(tmp) break