示例#1
0
 def process_event(self, cmd, value, ip, peerInfo, _prep):
     if cmd.startswith("HELO_LOGFILE"):
         if self.w == None:
             return
         from lunchinator.datathread.dt_qthread import DataReceiverThread
         #someone will send me his logfile on tcp
         values = value.split()
         file_size=int(values[0])
         tcp_port = 0
         if len(values) > 1:
             tcp_port = int(values[1])
         
         pID = peerInfo.get(LunchPeers.PEER_ID_KEY, ip)
         
         logDir = os.path.join(get_settings().get_main_config_dir(), "logs", pID)
         if not os.path.exists(logDir):
             os.makedirs(logDir)
         
         if cmd.startswith("HELO_LOGFILE_TGZ"):
             file_name= os.path.join(logDir, "tmp.tgz")
         else:
             file_name= os.path.join(logDir, "tmp.log")
         
         dr = DataReceiverThread.receiveSingleFile(ip, file_name, file_size, tcp_port, self.logger, "log%s"%ip, parent=self.w)
         dr.successfullyTransferred.connect(self.w.membersWidget.cb_log_transfer_success)
         dr.errorOnTransfer.connect(self.w.membersWidget.cb_log_transfer_error)
         dr.finished.connect(dr.deleteLater)
         dr.start()
示例#2
0
 def receiveFileSlot(self, addr, file_size, file_name, tcp_port, successFunc, errorFunc):
     addr = convert_string(addr)
     file_name = convert_string(file_name)
     dr = DataReceiverThread.receiveSingleFile(addr, file_name, file_size, tcp_port, getCoreLogger(), "avatar%s" % addr, True, parent=self)
     if successFunc:
         dr.successfullyTransferred.connect(lambda _thread, _path : successFunc())
     if errorFunc:
         dr.errorOnTransfer.connect(lambda _thread, _msg : errorFunc())
     dr.successfullyTransferred.connect(self.successfullyReceivedFile)
     dr.errorOnTransfer.connect(self.errorOnTransfer)
     dr.finished.connect(dr.deleteLater)
     dr.start()