Exemple #1
0
 def run(self):
     self.init()
     log.info("Local service is running!")
     while True:
         folders = self.db_client.get_active_local_sources()
         for folder_info in folders:
             if not os.path.exists(folder_info[1]):
                 log.critical(folder_info[1] + " does not exist.")
         for folder_info in folders:
             for file_name in os.listdir(folder_info[1]):
                 basename = os.path.join(folder_info[1], file_name)
                 if self.conf[0] == 1:
                     if basename[-5:] == ".meta":
                         continue
                 handle_new_file(self.db_client, basename, True, 1, folder_info[0])
             time.sleep(5)
Exemple #2
0
 def run(self):
     self.init()
     log.info("Local service is running!")
     while True:
         folders = self.db_client.get_active_local_sources()
         for folder_info in folders:
             if not os.path.exists(folder_info[1]):
                 log.critical(folder_info[1] + " does not exist.")
         for folder_info in folders:
             for file_name in os.listdir(folder_info[1]):
                 basename = os.path.join(folder_info[1], file_name)
                 if self.conf[0] == 1:
                     if basename[-5:] == ".meta":
                         continue
                 handle_new_file(self.db_client, basename, True, 1,
                                 folder_info[0])
             time.sleep(5)
Exemple #3
0
        m.update(file_content)
        md5 = m.hexdigest()
        
        if md5 != self.file_md5:
            log.error("File MD5 does not match")
            log.debug("MD5 : "+md5+" (vs "+self.file_md5+")")
            self.must_stop = True
            return
        
        self.file_temp_path = os.path.join("/tmp/",self.file_md5)
        fHandle = open(self.file_temp_path,"w")
        fHandle.write(file_content)
        fHandle.close()
        
        self.state_file_received = True
        code = handle_new_file(self.db_client,self.file_temp_path,True,2,self.remote_source_id)
        if code == 0:
            log.warning("File could not been queued, returning error code to remote client")
        code = chr(code)
        try:
            self.s.send(code)
        except Exception,e:
            log.error("Network send error")
            log.debug("Exception %s" % e)
            self.must_stop = True
            return

        return
    
    # Receives metadata
    #   - recv 1 dword: meta file size
Exemple #4
0
        m.update(file_content)
        md5 = m.hexdigest()

        if md5 != self.file_md5:
            log.error("File MD5 does not match")
            log.debug("MD5 : " + md5 + " (vs " + self.file_md5 + ")")
            self.must_stop = True
            return

        self.file_temp_path = os.path.join("/tmp/", self.file_md5)
        fHandle = open(self.file_temp_path, "w")
        fHandle.write(file_content)
        fHandle.close()

        self.state_file_received = True
        code = handle_new_file(self.db_client, self.file_temp_path, True, 2,
                               self.remote_source_id)
        if code == 0:
            log.warning(
                "File could not been queued, returning error code to remote client"
            )
        code = chr(code)
        try:
            self.s.send(code)
        except Exception, e:
            log.error("Network send error")
            log.debug("Exception %s" % e)
            self.must_stop = True
            return

        return