def serverStopped(self, _exit_code):
     get_settings().write_config_to_hd()
     if get_settings().get_plugins_enabled():
         get_plugin_manager().deactivatePlugins(get_plugin_manager().getAllPlugins(), save_state=False)
     get_notification_center().disconnectPluginActivated(self._checkSendInfoDict)
     get_notification_center().disconnectPluginDeactivated(self._checkSendInfoDict)
     get_notification_center().finish()
     DataReceiverThread.cleanup()
 def receiveFile(self, ip, fileSize, fileName, tcp_port, successFunc=None, errorFunc=None):
     getCoreLogger().info("Receiving file of size %d on port %d", fileSize, tcp_port)
     dr = DataReceiverThread.receiveSingleFile(ip, fileName, fileSize, tcp_port, getCoreLogger(), "avatar%s" % ip, True, successFunc, errorFunc)
     dr.start()
 def getOpenPort(self, ip):
     return DataReceiverThread.getOpenPort(category="avatar%s" % ip)
    sendDict = DataThreadBase.prepareSending(filesOrData, targetName, "gz")
    sendAndReceive(filesOrData, totalSize, targetDir, sendDict)
    if not testResult(filesOrData, targetDir, targetName, useTarstream=True):
        errors = True
        
    return not errors
      
if __name__ == '__main__':
    initializeLogger()
    
    get_settings().set_verbose(True)
    
    errors = False
    
    # test opening ports
    p1 = DataReceiverThread.getOpenPort()
    p2 = DataReceiverThread.getOpenPort()
    assert p1 != p2
    if p1 != get_settings().get_tcp_port():
        getCoreLogger().error("Did not obtain default TCP port")
        errors = True
    
    DataReceiverThread.cleanup()
    sys.exit(0)
    
    sourceDir = mkdtemp()
    targetDir = mkdtemp()
    
    FILE_SIZE = 1024 * 1024
    
    try: