Skip to content

Commit 8a1e033

Browse files
fix
2 parents 6b3b71b + 92f44e8 commit 8a1e033

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2091
-404
lines changed

.github/workflows/ci-test.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
on: [push]
2+
name: Run Test Cases
3+
jobs:
4+
test:
5+
strategy:
6+
fail-fast: false
7+
max-parallel: 1
8+
matrix:
9+
python_version: ['2.7', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9']
10+
runs-on: ubuntu-18.04
11+
steps:
12+
- name: Checkout repo
13+
uses: actions/checkout@v2
14+
with:
15+
ref: ${{ github.ref }}
16+
- name: Setup python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: ${{ matrix.python_version }}
20+
architecture: x64
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install flake8 pytest pytest-cov freezegun requests scrutinizer-ocular codecov
25+
- name: Run cases
26+
env:
27+
QINIU_ACCESS_KEY: ${{ secrets.QINIU_ACCESS_KEY }}
28+
QINIU_SECRET_KEY: ${{ secrets.QINIU_SECRET_KEY }}
29+
QINIU_TEST_BUCKET: ${{ secrets.QINIU_TEST_BUCKET }}
30+
QINIU_TEST_DOMAIN: ${{ secrets.QINIU_TEST_DOMAIN }}
31+
QINIU_TEST_ENV: "travis"
32+
PYTHONPATH: "$PYTHONPATH:."
33+
run: |
34+
set -e
35+
flake8 --show-source --max-line-length=160 .
36+
py.test --cov qiniu
37+
ocular --data-file .coverage
38+
coverage run test_qiniu.py
39+
codecov

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ nosetests.xml
4444
.mr.developer.cfg
4545
.project
4646
.pydevproject
47+
/.idea
48+
/.venv

.travis.yml

-29
This file was deleted.

CHANGELOG.md

+70-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,83 @@
11
# Changelog
22

3-
# 7.2.2 (2018-05-10)
3+
4+
## 7.8.0(2022-06-08)
5+
* 对象存储,管理类 API 发送请求时增加 [X-Qiniu-Date](https://developer.qiniu.com/kodo/3924/common-request-headers) (生成请求的时间) header
6+
7+
## 7.7.1 (2022-05-11)
8+
* 对象存储,修复上传不制定 key 部分情况下会上传失败问题。
9+
10+
## 7.7.0 (2022-04-29)
11+
* 对象存储,新增 set_object_lifecycle (设置 Object 生命周期) API
12+
13+
## 7.6.0 (2022-03-28)
14+
* 优化了错误处理机制
15+
* 支持 [Qiniu](https://developer.qiniu.com/kodo/1201/access-token) 签名算法
16+
17+
## 7.5.0 (2021-09-23)
18+
* 上传策略新增对部分字段支持
19+
20+
## 7.4.1 (2021-05-25)
21+
* 分片上传 v2 方法不再强制要求 bucket_name 参数
22+
23+
## 7.4.0 (2021-05-21)
24+
* 支持分片上传 v2
25+
26+
## 7.3.1 (2021-01-06)
27+
* 修复 ResponseInfo 对扩展码错误处理问题
28+
* 增加 python v3.7,v3.8,v3.9 版本 CI 测试
29+
30+
## 7.3.0 (2020-09-23)
31+
新增
32+
* sms[云短信]:新增查询短信发送记录方法:get_messages_info
33+
* cdn: 新增上线域名 domain_online 方法、下线域名 domain_offline 方法和删除域名 delete_domain 方法
34+
* 对象存储:新增批量解冻build_batch_restoreAr方法、获取空间列表bucket_domain方法和修改空间访问权限change_bucket_permission方法
35+
36+
## 7.2.10 (2020-08-21)
37+
* 修复上传策略中forceSaveKey参数没有签算进上传token,导致上传失败的问题
38+
## 7.2.9 (2020-08-07)
39+
* 支持指定本地ctx缓存文件.qiniu_pythonsdk_hostscache.json 文件路径
40+
* 更正接口返回描述docstring
41+
* 修复接口对非json response 处理
42+
* ci 覆盖增加python 3.6 3.7
43+
* 修复获取域名列方法
44+
* 修复python3 环境下,二进制对象上传问题
45+
46+
47+
## 7.2.8(2020-03-27)
48+
* add restoreAr
49+
50+
## 7.2.7(2020-03-10)
51+
* fix bucket_info
52+
53+
## 7.2.6(2019-06-26)
54+
* 添加sms
55+
56+
## 7.2.5 (2019-06-06)
57+
* 添加sms
58+
59+
## 7.2.4 (2019-04-01)
60+
* 默认导入region类
61+
62+
## 7.2.3 (2019-02-25)
63+
* 新增region类,zone继承
64+
* 上传可以指定上传域名
65+
* 新增上传指定上传空间和qvm指定上传内网的例子
66+
* 新增列举账号空间,创建空间,查询空间信息,改变文件状态接口,并提供例子
67+
68+
## 7.2.2 (2018-05-10)
469
* 增加连麦rtc服务端API功能
570

6-
# 7.2.0(2017-11-23)
71+
## 7.2.0(2017-11-23)
772
* 修复put_data不支持file like object的问题
873
* 增加空间写错时,抛出异常提示客户的功能
974
* 增加创建空间的接口功能
1075

11-
# 7.1.9(2017-11-01)
76+
## 7.1.9(2017-11-01)
1277
* 修复python2情况下,中文文件名上传失败的问题
1378
* 修复python2环境下,中文文件使用分片上传时失败的问题
1479

15-
# 7.1.8 (2017-10-18)
80+
## 7.1.8 (2017-10-18)
1681
* 恢复kirk的API为原来的状态
1782

1883
## 7.1.7 (2017-09-27)
@@ -35,7 +100,7 @@
35100

36101
## 7.1.2 (2017-03-24)
37102
### 增加
38-
* 增加设置文件生命周期的接口
103+
* 增加设置文件生命周期的接口
39104

40105
## 7.1.1 (2017-02-03)
41106
### 增加

README.md

+9-12
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
[![@qiniu on weibo](http://img.shields.io/badge/weibo-%40qiniutek-blue.svg)](http://weibo.com/qiniutek)
44
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
5-
[![Build Status](https://travis-ci.org/qiniu/python-sdk.svg)](https://travis-ci.org/qiniu/python-sdk)
5+
[![Build Status](https://github.com/qiniu/python-sdk/actions/workflows/ci-test.yml/badge.svg)](https://travis-ci.org/qiniu/python-sdk)
6+
[![GitHub release](https://img.shields.io/github/v/tag/qiniu/python-sdk.svg?label=release)](https://github.com/qiniu/python-sdk/releases)
67
[![Latest Stable Version](https://img.shields.io/pypi/v/qiniu.svg)](https://pypi.python.org/pypi/qiniu)
78
[![Download Times](https://img.shields.io/pypi/dm/qiniu.svg)](https://pypi.python.org/pypi/qiniu)
89
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/qiniu/python-sdk/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/qiniu/python-sdk/?branch=master)
9-
[![Code Coverage](https://scrutinizer-ci.com/g/qiniu/python-sdk/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/qiniu/python-sdk/?branch=master)
10+
[![Coverage Status](https://codecov.io/gh/qiniu/python-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/python-sdk)
11+
1012
## 安装
1113

1214
通过pip
@@ -17,10 +19,10 @@ $ pip install qiniu
1719

1820
## 运行环境
1921

20-
| Qiniu SDK版本 | Python 版本 |
21-
|:--------------------:|:---------------------------:|
22-
| 7.x | 2.6, 2.7, 3.3, 3.4, 3.5|
23-
| 6.x | 2.6, 2.7 |
22+
| Qiniu SDK版本 | Python 版本 |
23+
| :-----------: | :------------------------------------: |
24+
| 7.x | 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9 |
25+
| 6.x | 2.7 |
2426

2527
## 使用方法
2628

@@ -42,11 +44,6 @@ import qiniu
4244

4345
```
4446
更多参见SDK使用指南: http://developer.qiniu.com/code/v7/sdk/python.html
45-
46-
### 命令行工具
47-
安装完后附带有命令行工具,可以计算etag
48-
```bash
49-
$ qiniupy etag yourfile
5047
```
5148
5249
## 测试
@@ -58,7 +55,7 @@ $ py.test
5855
## 常见问题
5956

6057
- 第二个参数info保留了请求响应的信息,失败情况下ret 为none, 将info可以打印出来,提交给我们。
61-
- API 的使用 demo 可以参考 [单元测试](https://github.com/qiniu/python-sdk/blob/master/test_qiniu.py)
58+
- API 的使用 demo 可以参考 [examples示例](https://github.com/qiniu/python-sdk/tree/master/examples)
6259
- 如果碰到`ImportError: No module named requests.auth` 请安装 `requests`
6360

6461
## 代码贡献
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http:wxCLv4yl_5saIuOHbbZbkP-Ef3kFFFeCDYmwTdg3:upload30": {"upHosts": ["http://up.qiniu.com", "http://upload.qiniu.com", "-H up.qiniu.com http://183.131.7.3"], "ioHosts": ["http://iovip.qbox.me"], "deadline": 1598428478}}

examples/batch_copy.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
4+
25
"""
36
批量拷贝文件
47

examples/batch_delete.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
24
"""
35
批量删除文件
46

examples/batch_move.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
24
"""
35
批量移动文件
46

examples/batch_rename.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
24
"""
35
批量重命名文件
46

examples/batch_restoreAr.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
4+
"""
5+
批量解冻文件
6+
https://developer.qiniu.com/kodo/api/1250/batch
7+
"""
8+
9+
from qiniu import build_batch_restoreAr, Auth, BucketManager
10+
11+
# 七牛账号的公钥和私钥
12+
access_key = '<access_key>'
13+
secret_key = '<secret_key>'
14+
15+
q = Auth(access_key, secret_key)
16+
17+
bucket = BucketManager(q)
18+
19+
# 存储空间
20+
bucket_name = "空间名"
21+
22+
# 字典的键为需要解冻的文件,值为解冻有效期1-7
23+
ops = build_batch_restoreAr(bucket_name,
24+
{"test00.png": 1,
25+
"test01.jpeg": 2,
26+
"test02.mp4": 3
27+
}
28+
)
29+
30+
ret, info = bucket.batch(ops)
31+
print(info)

examples/batch_stat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
24
"""
35
批量查询文件信息
46
57
https://developer.qiniu.com/kodo/api/1250/batch
68
"""
79

8-
910
from qiniu import build_batch_stat, Auth, BucketManager
1011

1112
access_key = ''
12-
1313
secret_key = ''
1414

1515
q = Auth(access_key, secret_key)

examples/bucket_domain.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
4+
from qiniu import Auth
5+
from qiniu import BucketManager
6+
7+
"""
8+
获取空间绑定的加速域名
9+
https://developer.qiniu.com/kodo/api/3949/get-the-bucket-space-domain
10+
"""
11+
12+
# 七牛账号的 公钥和私钥
13+
access_key = '<access_key>'
14+
secret_key = '<secret_key>'
15+
16+
# 空间名
17+
bucket_name = ''
18+
19+
q = Auth(access_key, secret_key)
20+
21+
bucket = BucketManager(q)
22+
23+
ret, info = bucket.bucket_domain(bucket_name)
24+
print(info)

examples/bucket_info.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
4+
from qiniu import Auth
5+
from qiniu import BucketManager
6+
7+
# 需要填写你的 Access Key 和 Secret Key
8+
access_key = ''
9+
secret_key = ''
10+
11+
# 空间名
12+
bucket_name = 'bucket_name'
13+
14+
q = Auth(access_key, secret_key)
15+
16+
bucket = BucketManager(q)
17+
18+
ret, info = bucket.bucket_info(bucket_name)
19+
print(info)

examples/cdn_bandwidth.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
24
"""
35
查询指定域名指定时间段内的带宽
46
"""

examples/cdn_flux.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
24
"""
35
查询指定域名指定时间段内的流量
46
"""

examples/cdn_log.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
24
"""
35
获取指定域名指定时间内的日志链接
46
"""

examples/change_bucket_permission.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
4+
from qiniu import Auth
5+
from qiniu import BucketManager
6+
7+
# 需要填写七牛账号的 公钥和私钥
8+
access_key = '<access_key>'
9+
secret_key = '<secret_key>'
10+
11+
# 空间名
12+
bucket_name = ""
13+
14+
# private 参数必须是str类型,0表示公有空间,1表示私有空间
15+
private = "0"
16+
17+
q = Auth(access_key, secret_key)
18+
19+
bucket = BucketManager(q)
20+
21+
ret, info = bucket.change_bucket_permission(bucket_name, private)
22+
print(info)

0 commit comments

Comments
 (0)