Ejemplo n.º 1
0
    def receiveFile(self, filename, fileId, token=""):
        """
    Receive a file from the server

    @type filename : string / file descriptor / file object
    @param filename : File to receive from server
    @type fileId : any
    @param fileId : Identification of the file being received
    @type token : string
    @param token : Optional token for the file
    @return : S_OK/S_ERROR
    """
        fileHelper = FileHelper()
        retVal = fileHelper.getDataSink(filename)
        if not retVal['OK']:
            return retVal
        dS = retVal['Value']
        closeAfterUse = retVal['closeAfterUse']
        try:
            retVal = self._sendTransferHeader("ToClient", (fileId, token))
            if not retVal['OK']:
                return retVal
            transport = retVal['Value']
            fileHelper.setTransport(transport)
            retVal = fileHelper.networkToDataSink(dS)
            if not retVal['OK']:
                return retVal
            retVal = transport.receiveData()
            self._disconnect()
            if closeAfterUse:
                dS.close()
            return retVal
        finally:
            self._disconnect()
Ejemplo n.º 2
0
    def sendFile(self, filename, fileId, token=""):
        """
    Send a file to server

    @type filename : string / file descriptor / file object
    @param filename : File to send to server
    @type fileId : any
    @param fileId : Identification of the file being sent
    @type token : string
    @param token : Optional token for the file
    @return : S_OK/S_ERROR
    """
        fileHelper = FileHelper()
        retVal = fileHelper.getFileDescriptor(filename, "r")
        if not retVal['OK']:
            return retVal
        fd = retVal['Value']
        try:
            retVal = self._sendTransferHeader(
                "FromClient", (fileId, token, File.getSize(filename)))
            if not retVal['OK']:
                return retVal
            transport = retVal['Value']
            fileHelper.setTransport(transport)
            retVal = fileHelper.FDToNetwork(fd)
            if not retVal['OK']:
                return retVal
            retVal = transport.receiveData()
            return retVal
        finally:
            self._disconnect()
Ejemplo n.º 3
0
  def receiveFile( self, filename, fileId, token = "" ):
    """
    Receive a file from the server

    @type filename : string / file descriptor / file object
    @param filename : File to receive from server
    @type fileId : any
    @param fileId : Identification of the file being received
    @type token : string
    @param token : Optional token for the file
    @return : S_OK/S_ERROR
    """
    fileHelper = FileHelper()
    retVal = fileHelper.getDataSink( filename )
    if not retVal[ 'OK' ]:
      return retVal
    dS = retVal[ 'Value' ]
    closeAfterUse = retVal[ 'closeAfterUse' ]
    retVal = self._sendTransferHeader( "ToClient", ( fileId, token ) )
    if not retVal[ 'OK' ]:
      return retVal
    trid, transport = retVal[ 'Value' ]
    try:
      fileHelper.setTransport( transport )
      retVal = fileHelper.networkToDataSink( dS )
      if not retVal[ 'OK' ]:
        return retVal
      retVal = transport.receiveData()
      if closeAfterUse:
        dS.close()
      return retVal
    finally:
      self._disconnect( trid )
Ejemplo n.º 4
0
  def sendFile( self, filename, fileId, token = "" ):
    """
    Send a file to server

    @type filename : string / file descriptor / file object
    @param filename : File to send to server
    @type fileId : any
    @param fileId : Identification of the file being sent
    @type token : string
    @param token : Optional token for the file
    @return : S_OK/S_ERROR
    """
    fileHelper = FileHelper()
    retVal = fileHelper.getFileDescriptor( filename, "r" )
    if not retVal[ 'OK' ]:
      return retVal
    fd = retVal[ 'Value' ]
    retVal = self._sendTransferHeader( "FromClient", ( fileId, token, File.getSize( filename ) ) )
    if not retVal[ 'OK' ]:
      return retVal
    trid, transport = retVal[ 'Value' ]
    try:
      fileHelper.setTransport( transport )
      retVal = fileHelper.FDToNetwork( fd )
      if not retVal[ 'OK' ]:
        return retVal
      retVal = transport.receiveData()
      return retVal
    finally:
      self._disconnect( trid )
Ejemplo n.º 5
0
    def receiveFile(self, filename, fileId, token=""):
        """
        Receive a file from the server

        :type filename: string / file descriptor / file object
        :param filename: File to receive from server
        :type fileId: any
        :param fileId: Identification of the file being received
        :type token: string
        :param token: Optional token for the file
        :return: S_OK/S_ERROR
        """
        fileHelper = FileHelper()
        if "NoCheckSum" in token:
            fileHelper.disableCheckSum()
        retVal = fileHelper.getDataSink(filename)
        if not retVal["OK"]:
            return retVal
        dS = retVal["Value"]
        closeAfterUse = retVal["closeAfterUse"]
        retVal = self._sendTransferHeader("ToClient", (fileId, token))
        if not retVal["OK"]:
            return retVal
        trid, transport = retVal["Value"]
        try:
            fileHelper.setTransport(transport)
            retVal = fileHelper.networkToDataSink(dS)
            if not retVal["OK"]:
                return retVal
            retVal = transport.receiveData()
            if closeAfterUse:
                dS.close()
            return retVal
        finally:
            self._disconnect(trid)
Ejemplo n.º 6
0
    def sendFile(self, filename, fileId, token=""):
        """
        Send a file to server

        :type filename: string / file descriptor / file object
        :param filename: File to send to server
        :type fileId: any
        :param fileId: Identification of the file being sent
        :type token: string
        :param token: Optional token for the file
        :return: S_OK/S_ERROR
        """
        fileHelper = FileHelper()
        if "NoCheckSum" in token:
            fileHelper.disableCheckSum()
        retVal = fileHelper.getFileDescriptor(filename, "r")
        if not retVal["OK"]:
            return retVal
        fd = retVal["Value"]
        retVal = self._sendTransferHeader(
            "FromClient", (fileId, token, File.getSize(filename)))
        if not retVal["OK"]:
            return retVal
        trid, transport = retVal["Value"]
        try:
            fileHelper.setTransport(transport)
            retVal = fileHelper.FDToNetwork(fd)
            if not retVal["OK"]:
                return retVal
            retVal = transport.receiveData()
            return retVal
        finally:
            self._disconnect(trid)