GridFTP

gridftp interface

iceprod.core.gridftp.listify(lines, details=False, dotfiles=False)[source]

Turn ls output into a list of NamedTuples

class iceprod.core.gridftp.GridFTP[source]

GridFTP interface to command line client.

Example

GridFTP.get(‘gsiftp://data.icecube.wisc.edu/file’,

filename=’/path/to/file’)

classmethod supported_address(address)[source]

Return False for address types that are not supported

classmethod address_split(address)[source]

Split an address into server/path parts

classmethod get(address, filename=None, request_timeout=None)[source]

Do a GridFTP get request.

Either data is returned directly or filename must be defined.

Parameters:
  • address (str) – url to get from

  • filename (str) – filename to write data to

  • request_timeout (float) – timeout in secodns

Returns:

data, if filename is not defined

Return type:

str

Raises:

Exception for failure

classmethod put(address, data=None, filename=None, request_timeout=None)[source]

Do a GridFTP put request.

Either data or filename must be defined.

Parameters:
  • address (str) – url to put to

  • data (str) – the data to put

  • filename (str) – filename for data to put

  • request_timeout (float) – timeout in seconds

Raises:

Exception for failure

classmethod list(address, request_timeout=None, details=False, dotfiles=False)[source]

Do a GridFTP list request.

Parameters:
  • address (str) – url to list

  • request_timeout (float) – timeout in seconds

  • details (bool) – result is a list of NamedTuples

  • dotfiles (bool) – result includes ‘.’, ‘..’, and other ‘.’ files

Returns:

a list of files

Return type:

list

Raises:

Exception on error

classmethod mkdir(address, request_timeout=None, parents=False)[source]

Make a directory on the ftp server.

Parameters:
  • address (str) – url to directory

  • request_timeout (float) – timeout in seconds

  • parents (bool) – make parent directories as needed

Raises:

Exception on error

classmethod rmdir(address, request_timeout=None)[source]

Remove a directory on the ftp server.

This fails if the directory is not empty. Use rmtree() for recursive removal.

Parameters:
  • address (str) – url to directory

  • request_timeout (float) – timeout in seconds

Raises:

Exception on error

classmethod delete(address, request_timeout=None)[source]

Delete a file on the ftp server.

Parameters:
  • address (str) – url to file

  • request_timeout (float) – timeout in seconds

Raises:

Exception on error

classmethod rmtree(address, request_timeout=None)[source]

Delete a file or directory on the ftp server.

This is recursive, like rm -rf.

Parameters:
  • address (str) – url to file or directory

  • request_timeout (float) – timeout in seconds

Raises:

Exception on error

classmethod move(src, dest, request_timeout=None)[source]

Move a file on the ftp server.

Parameters:
  • src (str) – url to source file

  • dest (str) – url to destination file

  • request_timeout (float) – timeout in seconds

Raises:

Exception on error

classmethod exists(address, request_timeout=None)[source]

Check if a file exists on the ftp server.

Parameters:
  • address (str) – url to file

  • request_timeout (float) – timeout in seconds

Raises:

Exception on error

classmethod chmod(address, mode, request_timeout=None)[source]

Chmod a file on the ftp server.

Parameters:
  • address (str) – url to file

  • mode (str) – mode of file

  • request_timeout (float) – timeout in seconds

Raises:

Exception on error

classmethod size(address, request_timeout=None)[source]

Get the size of a file on the ftp server.

Parameters:
  • address (str) – url to file

  • request_timeout (float) – timeout in seconds

Returns:

size of file in bytes

Return type:

int

Raises:

Exception on error

classmethod md5sum(address, request_timeout=None)[source]

Get the md5sum of a file on an ftp server.

Parameters:
  • address (str) – url to file

  • request_timeout (float) – timeout in seconds

Returns:

the md5sum

Return type:

str

Raises:

Exception on error

classmethod sha1sum(address, request_timeout=None)[source]

Get the sha1sum of a file on an ftp server.

Parameters:
  • address (str) – url to file

  • request_timeout (float) – timeout in seconds

Returns:

the sha1sum

Return type:

str

Raises:

Exception on error

classmethod sha256sum(address, request_timeout=None)[source]

Get the sha256sum of a file on an ftp server.

Parameters:
  • address (str) – url to file

  • request_timeout (float) – timeout in seconds

Returns:

the sha256sum

Return type:

str

Raises:

Exception on error

classmethod sha512sum(address, request_timeout=None)[source]

Get the sha512sum of a file on an ftp server.

Parameters:
  • address (str) – url to file

  • request_timeout (float) – timeout in seconds

Returns:

the sha512sum

Return type:

str

Raises:

Exception on error