Metadata-Version: 2.1
Name: transferfile
Version: 0.1
Summary: transfer file using ftp, scp or sftp
Home-page: https://github.com/somenzz/transferfile
Author: somenzz
Author-email: somenzz@163.com
License: MIT License        
        Copyright (c) 2021 somenzz        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.        
Keywords: transferfile
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: paramiko
Requires-Dist: scp

# transferfile

#### 介绍

sftp、ftp、scp、rsync 传输文件的统一接口，适用于不同系统的数据采集系统，如数据仓库。

#### 安装教程

```shell
pip install transferfile
```

#### 使用说明

采用简单工厂模式，传入的 type 有：
- ftp
- sftp
- scp
- rsync

```python
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，从而不使用密码：

```python
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_私钥文件，从而不需要密码

```python
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 目前需要配置好授信才可以使用，暂时不支持用户名和密码登录。

```python
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 编程技能。 
![](images/python-seven.jpg)


个人微信 「somenzz」

![](images/somenzz.JPG)







