semvec/pypi-packages huggingface dataset:
transferfile 0.7
transfer file using ftp, scp or sftp
License: MIT
Keywords: transferfile

# transferfile

#### 介绍

sftp、ftp、scp、rsync 传输文件的统一接口，无论哪一种传输方式，都可以适配。

程序适用于数据服务系统，如数据仓库对下游系统分发数据文件。

#### 安装

```shell
pip install transferfile
```

#### 使用说明

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



##### ftp

*请注意原路径和目标路径都是带文件名的路径*

传输 /path/to/src.txt 到 /path/to/dist.txt

```python
from transferfile import TransferFactory
client = TransferFactory.create(type = "ftp",host = "172.17.0.2",username = "admin",password= "admin")
client.put("/path/to/src.txt","/path/to/dist.txt")
```


如果目标路径 `/path/to/` 不存在，会递归创建。

如果程序运行在 linux 环境（utf8编码），而 ftp 服务器在 Windows 环境（GBK编码），为了文件名看起来不是乱码，可以指定服务端的编码方式为 GBK，指定特殊端口也是可以的，默认是 21

```python
from transferfile import TransferFactory
client = TransferFactory.create(type = "ftp",host = "172.17.0.2",port = 21,username = "admin",password= "admin",encoding = 'gbk')
client.put("/path/to/src.txt","/path/to/dist.txt")
```

下载文件使用 get，下载远程 /path/to/remote.txt 到本地 /path/to/local.txt：

```python
from transferfile import TransferFactory
client = TransferFactory.create(type = "ftp",host = "172.17.0.2",port = 21,username = "admin",password= "admin",encoding = 'gbk')
client.get("/path/to/local.txt","/path/to/remote.txt")
```



##### sftp，scp

*请注意原路径和目标路径都是带文件名路径*

用 scp 或 sftp 时只需要修改 type 参数为 scp 或 sftp 即可：

```python
from transferfile import TransferFactory
client = TransferFactory.create(type = "sftp",host = "172.17.0.2",username = "admin",password= "admin")
client.put("/path/to/src.txt","/path/to/dist.txt")
```

也可以指定 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.put("/path/to/src.txt","/path/to/dist.txt")
```

如果已经做好了 ssh 的授信，可以传入参数 load_system_host_keys = True，从而不需要密码

```python
from transferfile import TransferFactory
client = TransferFactory.create(type = "scp",host = "172.17.0.2",username = "admin", load_system_host_keys = True )
client.put("/path/to/src.txt","/path/to/dist.txt")
```

##### rsync

*请注意原路径和目标路径可以是文件名，也可以是目录*

rsync 目前需要配置好授信才可以使用，暂时不支持用户名和密码登录。

```python
from transferfile import TransferFactory
client = TransferFactory.create(type = "rsync",host = "172.17.0.2",username = "admin", load_system_host_keys = True)
client.put("/path/to/src.txt","/path/to/dist.txt")
```

##### 扩展点

由于 ftp 不支持传输目录，这里就没有做出传输整个目录的接口，要实现也不复杂，如果要实现就是递归读取目录的文件，然后一个一个传输。也可以压缩成一个文件后上传。

目前工作中暂时没有这个需求，都是生成好一个文件就传输这个文件，不需要上传整个目录。因此就没有实现。


#### 更新日志

**0.7: sftp 增加递归创建目标路径功能 。**

**0.6: ftp 增加 windows 类型目录的支持。**

**0.5: ftp 增加链接类型目录的支持。**

ftp 创建目录前会判定目录是否存在，如果不存在就递归创建目录。增加链接型的目录的支持。

例如 /data_file -> /home/user/data_file

之前目标路径必须是 /home/user/data_file/path/dist.dat

0.5 版本之后可以是 /data_file/path/dist.dat


#### 联系我

有问题，欢迎交流讨论。

公众号 「Python七号」，分享 Python 编程技能。 
![](images/python-seven.jpg)


个人微信 「somenzz」

![](images/somenzz.JPG)
leo-gmi 1.2.1
A terminal-based client for the Gemini protocol.
License: MIT
Keywords: leo gemini gopher http fediverse internet protocol www client

# leo

## a gemini client written in Python 3.

#### (UNIX-only, Windows support with WSL)    

### Instructions for use:
0) `$ pip install leo-gmi`
1) `$ leo --copy-config` to create a config file in `$XDG_CONFIG_HOME/leo` (falls back to `~/.config/leo`)
* If you don't want to put the config file in either of those places, `leo --print-config` prints out the config that you can then supply to leo with the `--config` option.
2) set options to your preferences in the `config.json` file.
    * `wrap_text` specifies whether to wrap text beyond a certain width.
    * `wrap_margin` specifies what that width should be.
    * `homepage` is a page to load by default if no URL is specified.
    * `cert_path` is the path to a certificate file.

    _**Note**: You can specify an alternate config file with the `--config` option._

3) ```$ leo --url <url>```. If you do not specify a URL, the homepage set in `config.json` is loaded. If no homepage is set, you will be prompted for a URL.

4) if you'd like to connect providing a client certificate (required by certain Gemini servers), set the `"cert_path"` option in your config file to a valid path to a cert file.

5) Links are preceded by a number that is underlined and violet in colour. Type in the number of the link at the `(URL/Num):` prompt in order to navigate to a specific link, or type in a URL.  

6) Type `reload` to refresh a page. `reload hard` redownloads the page.  

7) `back` takes you one page back.  

8) `ls` lists all of the links on the current page, for easy navigation.

9) Type `help` at any time to view a listing of these and other useful commands.

10) Type ```exit``` or ```quit``` to exit leo.  

#### Features:
* Only uses the python standard library
* Fully implements Gemini spec
* Passes torture tests at gemini://gemini.conman.org/test/torture/ (Save for the final few Unicode ones, but Unicode support is hard)
* formatted text output with arbitrary wrapping support
* Comes with a built-in pager!
* Lets you save a list of URLs to a file for further viewing / opening in another window

### Contributing

Fork the repo and make a PR! That's all :) You can alternatively send me an e-mail with your patch.