utilities.py¶
Download and management utilities for syncing time and auxiliary files
- Can list a directory on a ftp host
- Can download a file from a ftp or http host
- Checks
MD5orsha1hashes between local and remote files
General Methods¶
-
cryosat_toolkit.utilities.get_data_path(relpath)¶ Get the absolute path within a package from a relative path
Arguments:
relpath: local relative path as list or string
-
cryosat_toolkit.utilities.get_hash(local, algorithm='MD5')¶ Get the hash value from a local file or BytesIO object
Arguments:
local: path to fileKeyword arguments:
algorithm: hashing algorithm for checksum validation'MD5': Message Digest'sha1': Secure Hash Algorithm
-
cryosat_toolkit.utilities.get_unix_time(time_string, format='%Y-%m-%d %H:%M:%S')¶ Get the Unix timestamp value for a formatted date string
Arguments:
time_string: formatted time string to parseKeyword arguments:
format: format for input time string
-
cryosat_toolkit.utilities.check_ftp_connection(HOST, username=None, password=None)¶ Check internet connection with ftp host
Arguments:
HOST: remote ftp hostKeyword arguments:
username: ftp usernamepassword: ftp password
-
cryosat_toolkit.utilities.ftp_list(HOST, username, password, timeout=None, basename=False, pattern=None, sort=False)¶ List a directory on a ftp host
Arguments:
HOST: remote ftp host path split as listKeyword arguments:
username: ftp server usernamepassword: ftp server passwordtimeout: timeout in seconds for blocking operationsbasename: return the file or directory basename instead of the full pathpattern: regular expression pattern for reducing listsort: sort output listReturns:
output: list of items in a directorymtimes: list of last modification times for items in the directory
-
cryosat_toolkit.utilities.from_ftp(HOST, username, password, timeout=None, local=None, hash='', chunk=16384, verbose=False, mode=0o775)¶ Download a file from a ftp host
Arguments:
HOST: remote ftp host path split as listKeyword arguments:
username: ftp server usernamepassword: ftp server passwordtimeout: timeout in seconds for blocking operationslocal: path to local filehash: MD5 hash of local filechunk: chunk size for transfer encodingverbose: print file transfer informationmode: permissions mode of output local file
-
cryosat_toolkit.utilities.from_http(HOST, timeout=None, local=None, hash='', chunk=16384, verbose=False, mode=0o775)¶ Download a file from a http host
Arguments:
HOST: remote http host path split as listKeyword arguments:
timeout: timeout in seconds for blocking operationslocal: path to local filehash: MD5 hash of local filechunk: chunk size for transfer encodingverbose: print file transfer informationmode: permissions mode of output local file
-
cryosat_toolkit.utilities.build_opener(context=ssl.SSLContext())¶ build urllib opener for ESA CryoSat-2 Science Server
Keyword arguments:
context: SSL context for opener object