通过scp将数据上载到远程www目录并返回公共url。

drop的Python项目详细描述


通过scp将数据上载到远程www目录并返回公共url。

安装

最简单的方法是通过pip安装:

pip install drop

目前除了Python2.7或Python3.4之外,没有其他依赖项。

要手动安装:将drop/drop.py复制到您喜欢的任何位置

配置

配置文件是必需的,它可以位于/etc/drop.cfg、~/.drop.cfg或通过命令行选项-config file传递的位置。

示例配置文件是:

[DEFAULT]
# reference to the default destination (section name):
destination = hawo

# You can set the following defaults:
# Location of the scp command, can be relative or absolute path:
scp = scp
# default length (in characters) for hashfilenames (max. 28)
hashlength = 28
# default chmod to apply to uploaded files (already applied localy and uploaded with -p)
# 436 this is 0o644
chmod = 436

# Destinations:
[hawo]
# remote server dns or alias from .ssh/config and may also include username (user@server):
remoteserver = ente
# remote directory can be relative (to home directory) or absolute:
remotedir = public_html/d/
# publishing url, this must represent the above directory:
url = http://hawo.net/~sijuhamm/d/
# all defaults can be overwritten for any destination. For example the hashlength:
hashlength = 10

默认部分为所有其他部分和默认目标配置默认值。所有其他部分都称为目的地部分。可以通过–destination命令行参数选择它们。

用法

您可以按参数发送文件:

$ drop defaults.cfg
http://hawo.net/~sijuhamm/d/NcT0jFb5.cfg

或通过stdin的任何内容:

$ date | ./drop.py
http://hawo.net/~sijuhamm/d/ephtK9DY

远程位置的文件名实际上是文件的部分sha1校验和。校验和的长度可以在配置文件中设置。尽可能保留扩展名,也可以使用–extension参数覆盖扩展名。

完整的帮助信息如下:

usage: drop [-h] [--destination DESTINATION] [--list-destinations]
            [--preserve-name] [--extension EXTENSION] [--config-file CONFIG_FILE]
            [--test] infile [infile ...]

Uploads data to a remote www directory via scp and returns a public url.

positional arguments:
  infile                File to upload. If multiple are passed, they will be
                        archived and compressed before uploading.

optional arguments:
  -h, --help            show this help message and exit
  --destination DESTINATION, -d DESTINATION
                        Name of destination as found in configuration file.
  --list-destinations, -l
                        List all destinations defined in configuration file.
  --preserve-name, -p   Will preserve original filename at remote location, by
                        adding an intermediate directory.
  --extension EXTENSION, -e EXTENSION
                        Overwrites extension on uploaded file.
  --config-file CONFIG_FILE, -c CONFIG_FILE
  --test                Runs a test on destination.

待办事项

即将推出的功能:
  • (可能)支持其他上传目的地
  • 支持更多压缩/存档格式

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java迭代图形框架聚合达到内存限制的消息   反编译和开发人员向Android应用程序提供java安全密钥   活页夹中的java Vaadin上传组件,例如Crud编辑器   java如何定义0090当我有了每个字符   带有AOP的java截取私有注释方法   在Java中暂停并恢复动画(thread.sleep)   java在JavaFX中从不同的控制器向TableView添加行   java如何通过Spring使用脚本初始化inmemory HSQLDB   windows找到了绝对的java。通过编程从java代码获取exe路径   Java同步、信号量和队列的多线程性能   java异步任务回调未调用   java在迷宫中用坐标寻找最短路径   Java:并行处理数组,查找发生异常的位置   java我无法理解我收到的错误   如何调用。bat文件,并使用java中的ProcessBuilder发送字符串   java在mysql数据库中插入日期   将ArrayList的内容显示为格式正确的JSON for Java REST API   java@OneToMany注释SQLSyntaxErrorException:ORA000904无效标识符