transfer file using ftp, scp or sftp
Project description
transferfile
介绍
sftp、ftp、scp、rsync 传输文件的统一接口,适用于不同系统的数据采集系统,如数据仓库。
安装教程
pip install transferfile
使用说明
采用简单工厂模式,传入的 type 有:
- ftp
- sftp
- scp
- rsync
from transferfile import TransferFactory
client = TransferFactory.create(type = "ftp",host = "172.17.0.2",port= 22,username = "admin",password= "admin")
client.put("./test_scp.py","/path/to/test_scp.py")
对于 scp、sftp 可以直接使用系统的 key,从而不使用密码:
from transferfile import TransferFactory
client = TransferFactory.create(type = "scp",host = "172.17.0.2",username = "admin", load_system_host_keys = True)
client.put("./test_scp.py","/path/to/test_scp.py")
也可以指定 rsa_私钥文件,从而不需要密码
from transferfile import TransferFactory
client = TransferFactory.create(type = "scp",host = "172.17.0.2",username = "admin", rsa_file = "/root/.ssh/id_rsa")
client.get("./test_scp.py","/path/to/test_scp.py")
rsync 目前需要配置好授信才可以使用,暂时不支持用户名和密码登录。
from transferfile import TransferFactory
client = TransferFactory.create(type = "rsync",host = "172.17.0.2",username = "admin", load_system_host_keys = True)
client.get("./test_scp.py","/path/to/test_scp.py")
联系我
有问题,欢迎交流讨论。
公众号 「Python七号」,分享 Python 编程技能。
个人微信 「somenzz」
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
transferfile-0.1.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file transferfile-0.1.tar.gz
.
File metadata
- Download URL: transferfile-0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78d510d7aa7933ccfd6bd2091b2551ca3e7654792ca6da92309b3ab222572bb4 |
|
MD5 | 0b61ccfb08c1a2f740ff2a9a7d2ec097 |
|
BLAKE2b-256 | 58bedcc2e0c75e5fbfeb6ce39632fb11b2694767201241f89934c684e5e8907f |
File details
Details for the file transferfile-0.1-py3-none-any.whl
.
File metadata
- Download URL: transferfile-0.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67da29a300f88d698fb6a4e2e298f6f849bf347c259864659a84193245119b2a |
|
MD5 | ab5a01c5d8d2c07367dd1e479eb3dfa9 |
|
BLAKE2b-256 | b6c6b0a22d4d7b420d52da2598b379f5ae7ebcb2a08833a743ffc36f5ccc7b89 |