Python Boilerplate contains all the boilerplate you need to create a Python package.
Project description
# 说明
本库封装了S3,Rabbitmq,Apscheduler,ssh, sftp, 以及常用的函数
## S3
使用boto3封装S3,
假设在settings已经配置好settings.S3
{"host": "s3.hypers.com.cn", "port": 80, "access_key": "OPL5N7K242QFEA4SL0PB", "secret_key": "VsSSacotwZCCcvTOqMApPaEAS1JN2WDTD7dVKJPe", "bucket": "aurora"}
使用方法如下
获取某个key的url
S3(key='test').url
下载S3文件到本地文件(tmp)
S3().download('test', 'tmp')
下载S3文件到BytesIO对象
bio = S3().download('test')
上传本地文件(test)到 S3路径(tmp)
S3().upload('test', 'tmp')
上传本地文件BytesIO文件(bio)到 S3路径(tmp)
bio = io.BytesIO()
bio.write(b'test')
bio.seek(0)
S3().upload(bio, 'tmp')
设置S3文件('tmp')的权限,其中public-read为公网匿名用户可读
S3().putACL('tmp', 'public-read')
## Rabbitmq
使用asyncio adapter封装rabbitmq的consumer,使用rabbitmq实现异步任务
假设在settings已经配置好settings.RABBITMQ, 如果没有配置,则在Queue实例化时吧配置传进去
{"host": "10.123.99.99",
"port": 5672,
"vhost": "/kk",
"user": "admin",
"password": "admin",
"queue": "aurora-test.back2front.calc.result.request.queue",
}
### Consumer
默认在callback函数调用完之后发送ack信号
@Queue()
def listen(body: dict):
print(body)
如果要在callback函数调用前发送ack信号
@Queue(ack='first')
def listen(body: dict):
print(body)
### Publisher
Queue().publish({'a': 'b'})
### 异步任务
from hyperstools.mq.asyncTasker
@asyncTasker.register
def mycallback(model, queryset):
pass
=======
History
=======
0.1.0 (2019-02-13)
------------------
* First release on PyPI.
本库封装了S3,Rabbitmq,Apscheduler,ssh, sftp, 以及常用的函数
## S3
使用boto3封装S3,
假设在settings已经配置好settings.S3
{"host": "s3.hypers.com.cn", "port": 80, "access_key": "OPL5N7K242QFEA4SL0PB", "secret_key": "VsSSacotwZCCcvTOqMApPaEAS1JN2WDTD7dVKJPe", "bucket": "aurora"}
使用方法如下
获取某个key的url
S3(key='test').url
下载S3文件到本地文件(tmp)
S3().download('test', 'tmp')
下载S3文件到BytesIO对象
bio = S3().download('test')
上传本地文件(test)到 S3路径(tmp)
S3().upload('test', 'tmp')
上传本地文件BytesIO文件(bio)到 S3路径(tmp)
bio = io.BytesIO()
bio.write(b'test')
bio.seek(0)
S3().upload(bio, 'tmp')
设置S3文件('tmp')的权限,其中public-read为公网匿名用户可读
S3().putACL('tmp', 'public-read')
## Rabbitmq
使用asyncio adapter封装rabbitmq的consumer,使用rabbitmq实现异步任务
假设在settings已经配置好settings.RABBITMQ, 如果没有配置,则在Queue实例化时吧配置传进去
{"host": "10.123.99.99",
"port": 5672,
"vhost": "/kk",
"user": "admin",
"password": "admin",
"queue": "aurora-test.back2front.calc.result.request.queue",
}
### Consumer
默认在callback函数调用完之后发送ack信号
@Queue()
def listen(body: dict):
print(body)
如果要在callback函数调用前发送ack信号
@Queue(ack='first')
def listen(body: dict):
print(body)
### Publisher
Queue().publish({'a': 'b'})
### 异步任务
from hyperstools.mq.asyncTasker
@asyncTasker.register
def mycallback(model, queryset):
pass
=======
History
=======
0.1.0 (2019-02-13)
------------------
* First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hyperstools-0.1.29.tar.gz
(21.4 kB
view hashes)
Built Distributions
hyperstools-0.1.29-py3.7.egg
(20.2 kB
view hashes)
Close
Hashes for hyperstools-0.1.29-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40c53dc8570bc380a1d0024f28ea4a8214e1b79158612d15e966552a91cca8f5 |
|
MD5 | 4e9120fb69fa1e967f02acb10264e181 |
|
BLAKE2b-256 | 7e843fa1abbb5b5929906935532f9cec51732fbc053de6b829f81e6f3946a562 |