Skip to main content

ftp

一个 ftp 下载器

包含 ftp 连接与下载器的方法

  • GFTP:新增 FTP 没有的方法
  • FTPConn:FTP 连接创建、快速重连
  • FTPDownloader:FTP 文件、文件列表、文件夹下载

安装

pip install gftp

GFTP

新增了一些 FTP 没有的方法

  • show_dir:列表形式返回文件夹下的所有文件、文件夹(返回全路径)
  • show_file:列表形式返回当前文件夹下的所有文件(返回全路径)
  • show_folder:列表形式返回当前文件夹下的所有文件夹(返回全路径)
  • iter_dir:遍历指定路径下的文件、文件夹并输出(迭代器,返回全路径)

这里就介绍下 iter_dir

from gftp import FTPConn

ftp = FTPConn(**连接配置)
for f in ftp.connection.iter_dir('/'):
    print(f)

FTPConn

创建连接用

from gftp import FTPConn

ftp = FTPConn(**连接配置)
ftp.connection.pwd()    # 通过 connection 使用 FTP 命令
ftp.reconnection()      # 重新连接
ftp.close()             # 关闭连接,会自动回收,关不关无所谓

FTPDownloader

下载文件、文件列表、文件夹
可以多线程,即创建多个连接
介绍两个参数:

  • 类实例参数 keep_structure 会在 save_path 的基础上,保留 ftp 目录结构
  • download 参数 callback 是线程,线程数量和类实例的 threads 数量一致
from gftp import FTPDownloader

downloader = FTPDownloader(**连接配置, save_path='')
downloader.download_file(ftp_path='xx', callback=xx)
downloader.download_list(ftp_path_list=['xx'], callback=xx)
downloader.download_dir(dir_path='xx', callback=xx)

Metadata

Release files for gftp 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gftp 0.0.7
File Size Uploaded
gftp-0.0.7.tar.gz 5.6 kB Details

Release files / gftp-0.0.7.tar.gz

Download URL gftp-0.0.7.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4541922fa7d1fe264d18cd9c19268890cec85f9d35a557a67cea184355daec63
BLAKE2b-256 checksum
How to use checksums
e9d5eab218d878b2a71227da2063115efb89e42ef1a705b410da4eb41d47978c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.0.7 This release

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page