Ftp¶
- class gdt.core.heasarc.Ftp(host='heasarc.gsfc.nasa.gov', progress: Progress = None, timeout: float = 90.0)[source]¶
Bases:
BaseProtocolA class for FTP interactions with a remote archive.
- Parameters:
host (str, optional) – The host of the FTP archive
progress (Progress, optional) – The progress bar object
timeout (float, optional) – Seconds to wait before timing out operation.
Attributes Summary
The list of files in the current directory
True if the protocol has been initialized with a host address
Number of files in the current directory
Methods Summary
cd(path)Change directory
connect([host])Attempt a connection
Politely disconnect from the FTP server.
download(file, dest_dir[, verbose])Downloads a single file from the current directory on a FTP site.
download_url(url, dest_dir[, verbose])Download a file from a FTP site url.
get(download_dir, files[, verbose])Downloads a list of files from the current directory.
ls(path, *[, fullpath])List the contents of a directory associated with a data set.
pwd_r()(str): the current directory.
Attributes Documentation
- files¶
The list of files in the current directory
- Type:
(list of str)
- initialized¶
True if the protocol has been initialized with a host address
- Type:
(bool)
- num_files¶
Number of files in the current directory
- Type:
(int)
Methods Documentation
- cd(path: str)¶
Change directory
- Parameters:
path (str) – The remote directory path
- connect(host: str = None)[source]¶
Attempt a connection
- Parameters:
host (str) – The host of the FTP archive
- download(file: str, dest_dir: Union[str, Path], verbose=True)[source]¶
Downloads a single file from the current directory on a FTP site.
- Parameters:
file (str) – The file name to download
dest_dir (Path) – The download file location
verbose (bool, optional) – If True, will output the download status. Default is True.
- Returns:
(Path)
- download_url(url: str, dest_dir: Union[str, Path], verbose: bool = True)[source]¶
Download a file from a FTP site url.
- Parameters:
url (str) – The url of a file to download
dest_dir (str, Path) – The directory where the file will be written
verbose (bool, optional) – If True, will output the download status. Default is True.
- Returns:
(Path)
- get(download_dir: Union[str, Path], files: List[str], verbose: bool = True) List[Path]¶
Downloads a list of files from the current directory. This function also returns a list of the downloaded file paths.
- Parameters:
download_dir (str, Path) – The download directory location
files (list of str) – The list of files to download
verbose (bool, optional) – If True, will output the download status. Default is True.
- Returns:
(list)
- ls(path: str, *, fullpath: bool = False) List[str]¶
List the contents of a directory associated with a data set.
- Parameters:
path (str) – The remote directory path
fullpath (bool, optional) – If
True, the contents of the directory will be returned with their full path
- Returns:
(list of str)