Module gridftpClient :: Class FTPClient
[hide private]
[frames] | no frames]

Class FTPClient

source code

object --+
         |
        FTPClient

A class to wrap the GridFTP client functions

Instance Methods [hide private]
instance of class GridFTPClient
__init__(self, handleAttr)
Constructs an instance.
source code
None
__del__(self)
Destroys an instance.
source code
None
add_plugin(self, plugin)
Add a plugin to the handle associated with this instance.
source code
None
remove_plugin(self, plugin)
Remove a plugin from the handle associated with this instance.
source code
None
third_party_transfer(self, src, dst, completeCallback, arg, srcOpAttr=None, dstOpAttr=None, restartMarker=None)
Initiate a third party transfer between to servers.
source code
None
get(self, url, completeCallback, arg, opAttr=None, marker=None)
Get a file from an FTP server.
source code
None
register_read(self, buffer, dataCallback, arg)
Register an instance of class Buffer and the function dataCallback to handle a part of the FTP data transfer.
source code
None
cksm(self, url, completeCallback, arg, opAttr=None, offset=None, length=None)
Get a file's checksum from an FTP server.
source code
None
mkdir(self, url, completeCallback, arg, opAttr=None)
Make a directory on a server.
source code
None
rmdir(self, url, completeCallback, arg, opAttr=None)
Remove a directory on a server.
source code
None
delete(self, url, completeCallback, arg, opAttr=None)
Delete a file on a server.
source code
None
move(self, src, dst, completeCallback, arg, opAttr=None)
Move or rename a file on a server.
source code
None
chmod(self, url, mode, completeCallback, arg, opAttr=None)
Change the mode of a file on a server.
source code
None
verbose_list(self, url, completeCallback, arg, opAttr=None)
Get a file listing from a FTP server.
source code
None
abort(self)
Abort the operation currently in progress.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, handleAttr)
(Constructor)

source code 

Constructs an instance. A wrapped pointer to the Globus C type globus_ftp_client_handle_t is stored in the ._handle attribute.

Parameters:
  • handleAttr (instance of HandleAttr class) - instance of the HandleAttr class
Returns: instance of class GridFTPClient
an instance of class GridFTPClient
Raises:
Overrides: object.__init__

__del__(self)
(Destructor)

source code 

Destroys an instance. The wrapped pointer to the Globus C type is used by globus_free() to free all the memory associated with the C type.

Returns: None
None
Raises:

add_plugin(self, plugin)

source code 

Add a plugin to the handle associated with this instance.

Parameters:
  • plugin (instance of PerformanceMarkerPlugin) - an instance of a plugin class, currently only the PerformanceMarkerPlugin class is supported
Returns: None
None
Raises:

remove_plugin(self, plugin)

source code 

Remove a plugin from the handle associated with this instance. The plugin must have already been added using the add_plugin() method.

Parameters:
  • plugin (instance of PerformanceMarkerPlugin) - an instance of a plugin class, currently only the PerformanceMarkerPlugin class is supported
Returns: None
None
Raises:

third_party_transfer(self, src, dst, completeCallback, arg, srcOpAttr=None, dstOpAttr=None, restartMarker=None)

source code 

Initiate a third party transfer between to servers. This function returns immediately. When the transfer is completed or if the transfer is aborted, the completeCallback function will be invoked with the final status of the transfer.

The completeCallback must have the form:

def completeCallback(arg, handle, error):

  • arg is the user argument passed in when the transfer was initiated
  • handle is the wrapped pointer to the client handle
  • error is None for success or a string if an error occurred
Parameters:
  • src (string) - the source URL for the transfer
  • dst (string) - the destination URL for the transfer
  • completeCallback (callable) - the function to call when the transfer is complete
  • arg (any) - user argument to pass to the completion callback
  • srcOpAttr (instance of OperationAttr) - an instance of OperationAttr for the source
  • dstOpAttr (instance of OperationAttr) - an instance of OperationAttr for the destination
  • restartMarker (None) - not currently supported, please pass in None
Returns: None
None
Raises:

get(self, url, completeCallback, arg, opAttr=None, marker=None)

source code 

Get a file from an FTP server.

This function starts a get file transfer from an FTP server. If this function returns without exception then the user may immediately begin calling register_read() to retrieve the data associated with this URL.

When all of the data associated with this URL is retrieved, and all of the data callbacks have been called, or if the get request is aborted, the completeCallback will be invoked with the final status of the get.

The completeCallback function must have the form:

def completeCallback(arg, handle, error):

  • arg is the user argument passed in when the transfer was initiated
  • handle is the wrapped pointer to the client handle
  • error is None for success or a string if an error occurred
Parameters:
  • url (string) - the source URL to get
  • completeCallback (callable) - function to call when the transfer is complete
  • arg (any) - user argument to pass to the callback
  • opAttr (instance of OperationAttr) - an instance of OperationAttr for the transfer
  • marker (None) - not currently supported, please pass in None
Returns: None
None
Raises:

register_read(self, buffer, dataCallback, arg)

source code 

Register an instance of class Buffer and the function dataCallback to handle a part of the FTP data transfer.

The instance of class Buffer will be associated with the current get being performed on this client handle and data will be written into the buffer. The user must then empty the buffer and register another instance for the transfer to proceed. Note that if parallel data channels are used multiple buffers should be registered.

When the instance of class Buffer is fulled the function dataCallback will be called.

The dataCallback function must have the form:

def dataCallback(arg, handle, buffer, length, offset, eof, error):

  • arg is the user argument passed in when this function is called
  • handle is the wrapped pointer to the client handle
  • buffer is the buffer from which the data can be read
  • length is the number of bytes in the buffer
  • offset is the offset into the file at which the bytes start
  • eof is true if this is the end of the file
  • error is None or a string if there is an error
Parameters:
  • buffer (instance of class Buffer) - instance of class Buffer into which the data will be written
  • dataCallback (callable) - function to be called when the instance of Buffer is full
  • arg (any) - user argument to pass to the callback function
Returns: None
None
Raises:
  • GridFTPException - raised if unable to register the buffer and callback for reading

cksm(self, url, completeCallback, arg, opAttr=None, offset=None, length=None)

source code 

Get a file's checksum from an FTP server.

This function requests the checksum of a file from an FTP server.

When the request is completed or aborted, the completeCallback will be invoked with the final status of the operation and the checksum value.

The completeCallback must have the form:

def completeCallback(cksm, arg, handle, error):

  • cksm is the Python string containing the checksum value
  • arg is the user argument passed in when the call was initiated
  • handle is the wrapper pointer to the client handle
  • error is None for success or a string if an error occurred
Parameters:
  • url (string) - the source URL for the file to be checksummed
  • completeCallback (callable) - the function to be called when the checksum operation is complete
  • arg (any) - user argument to pass to the callback function
  • opAttr (instance of OperationAttr) - an instance of OperationAttr for the source
  • offset (integer) - the offset in bytes into the file at which to begin computing the checkusm, use None to start at the beginning of the file
  • length (integer) - the length of the file in bytes to use when computing the checksum, use None to checksum the entire file
Returns: None
None
Raises:

mkdir(self, url, completeCallback, arg, opAttr=None)

source code 

Make a directory on a server.

When the request is completed or aborted, the completeCallback will be invoked with the final status of the operation.

The completeCallback must have the form:

def completeCallback(arg, handle, error):

  • arg is the user argument passed in when the call was initiated
  • handle is the wrapper pointer to the client handle
  • error is None for success or a string if an error occurred
Parameters:
  • url (string) - the source URL for the directory to be created
  • completeCallback (callable) - the function to be called when the mkdir operation is complete
  • arg (any) - user argument to pass to the callback function
  • opAttr (instance of OperationAttr) - an instance of OperationAttr for the source
Returns: None
None
Raises:

rmdir(self, url, completeCallback, arg, opAttr=None)

source code 

Remove a directory on a server.

When the request is completed or aborted, the completeCallback will be invoked with the final status of the operation.

The completeCallback must have the form:

def completeCallback(arg, handle, error):

  • arg is the user argument passed in when the call was initiated
  • handle is the wrapper pointer to the client handle
  • error is None for success or a string if an error occurred
Parameters:
  • url (string) - the source URL for the directory to be removed
  • completeCallback (callable) - the function to be called when the mkdir operation is complete
  • arg (any) - user argument to pass to the callback function
  • opAttr (instance of OperationAttr) - an instance of OperationAttr for the source
Returns: None
None
Raises:

delete(self, url, completeCallback, arg, opAttr=None)

source code 

Delete a file on a server.

When the request is completed or aborted, the completeCallback will be invoked with the final status of the operation.

The completeCallback must have the form:

def completeCallback(arg, handle, error):

  • arg is the user argument passed in when the call was initiated
  • handle is the wrapper pointer to the client handle
  • error is None for success or a string if an error occurred
Parameters:
  • url (string) - the source URL for the file to be deleted
  • completeCallback (callable) - the function to be called when the mkdir operation is complete
  • arg (any) - user argument to pass to the callback function
  • opAttr (instance of OperationAttr) - an instance of OperationAttr for the source
Returns: None
None
Raises:

move(self, src, dst, completeCallback, arg, opAttr=None)

source code 

Move or rename a file on a server.

When the request is completed or aborted, the completeCallback will be invoked with the final status of the operation.

The completeCallback must have the form:

def completeCallback(arg, handle, error):

  • arg is the user argument passed in when the call was initiated
  • handle is the wrapper pointer to the client handle
  • error is None for success or a string if an error occurred
Parameters:
  • src (string) - the source URL for the file to be moved
  • dst (string) - the destination URL for the file to be moved
  • completeCallback (callable) - the function to be called when the mkdir operation is complete
  • arg (any) - user argument to pass to the callback function
  • opAttr (instance of OperationAttr) - an instance of OperationAttr for the source
Returns: None
None
Raises:

chmod(self, url, mode, completeCallback, arg, opAttr=None)

source code 

Change the mode of a file on a server.

When the request is completed or aborted, the completeCallback will be invoked with the final status of the operation.

The completeCallback must have the form:

def completeCallback(arg, handle, error):

  • arg is the user argument passed in when the call was initiated
  • handle is the wrapper pointer to the client handle
  • error is None for success or a string if an error occurred
Parameters:
  • url (string) - the source URL for the file
  • mode (integer) - the integer file mode, be sure to use 4 digits, for example 0644 instead of 644.
  • completeCallback (callable) - the function to be called when the mkdir operation is complete
  • arg (any) - user argument to pass to the callback function
  • opAttr (instance of OperationAttr) - an instance of OperationAttr for the source
Returns: None
None
Raises:

verbose_list(self, url, completeCallback, arg, opAttr=None)

source code 

Get a file listing from a FTP server.

This function starts a verbose file listing from an FTP server. If this function returns without exception then the user may immediately begin calling register_read() to retrieve the data associated with this operation.

When all of the data associated with this URL is retrieved, and all of the data callbacks have been called, or if the verbose list request is aborted, the completeCallback will be invoked with the final status of the get.

The completeCallback function must have the form:

def completeCallback(arg, handle, error):

  • arg is the user argument passed in when the transfer was initiated
  • handle is the wrapped pointer to the client handle
  • error is None for success or a string if an error occurred
Parameters:
  • url (string) - the source URL from which to get the file listing
  • completeCallback (callable) - function to call when the listing is complete
  • arg (any) - user argument to pass to the callback
  • opAttr (instance of OperationAttr) - an instance of OperationAttr for the transfer
Returns: None
None
Raises:

abort(self)

source code 

Abort the operation currently in progress.

Returns: None
None
Raises: