def testReceive(openPort, targetPath, totalSize, sendDict):
    global errorReceive
    try:
        if sendDict is not None:
            dt = DataReceiverThreadBase.receive(SENDER, targetPath, openPort, sendDict, getCoreLogger())
        else:
            dt = DataReceiverThreadBase.receiveSingleFile(SENDER, targetPath, totalSize, openPort, getCoreLogger())
        dt.performReceive()
    except:
        errorReceive = True
        getCoreLogger().error(u"Error receiving: %s", formatException())
def sendAndReceive(filesOrData, totalSize=None, targetPath=None, sendDict=None):
    global errorSend, errorReceive
    errorSend = False
    errorReceive = False
    
    openPort = DataReceiverThreadBase.getOpenPort(False)
    sendThread = Thread(target=partial(testSend, openPort, filesOrData, sendDict))
    recvThread = Thread(target=partial(testReceive, openPort, targetPath, totalSize, sendDict))
    
    startTime = time.time()
    
    recvThread.start()
    sendThread.start()
    
    recvThread.join()
    sendThread.join()
    
    endTime = time.time()
    
    if not errorSend and not errorReceive:
        getCoreLogger().info("  transfer finished, runtime: %.2fs", (endTime - startTime))
Example #3
0
 def __init__(self, senderIP, portOrSocket, targetPath, overwrite, sendDict, category, logger, parent):
     QThread.__init__(self, parent)
     DataReceiverThreadBase.__init__(self, senderIP, portOrSocket, targetPath, overwrite, sendDict, category, logger)
Example #4
0
 def __init__(self, senderIP, portOrSocket, targetPath, overwrite, sendDict, category, logger, success_func=None, err_func=None):
     Thread.__init__(self)
     DataReceiverThreadBase.__init__(self, senderIP, portOrSocket, targetPath, overwrite, sendDict, category, logger) 
     
     self._successFunc = success_func
     self._errorFunc = err_func