Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jun 27, 2022
2 parents 6b3b71b + 92f44e8 commit 8a1e033
Show file tree
Hide file tree
Showing 52 changed files with 2,091 additions and 404 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on: [push]
name: Run Test Cases
jobs:
test:
strategy:
fail-fast: false
max-parallel: 1
matrix:
python_version: ['2.7', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9']
runs-on: ubuntu-18.04
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}
architecture: x64
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov freezegun requests scrutinizer-ocular codecov
- name: Run cases
env:
QINIU_ACCESS_KEY: ${{ secrets.QINIU_ACCESS_KEY }}
QINIU_SECRET_KEY: ${{ secrets.QINIU_SECRET_KEY }}
QINIU_TEST_BUCKET: ${{ secrets.QINIU_TEST_BUCKET }}
QINIU_TEST_DOMAIN: ${{ secrets.QINIU_TEST_DOMAIN }}
QINIU_TEST_ENV: "travis"
PYTHONPATH: "$PYTHONPATH:."
run: |
set -e
flake8 --show-source --max-line-length=160 .
py.test --cov qiniu
ocular --data-file .coverage
coverage run test_qiniu.py
codecov
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ nosetests.xml
.mr.developer.cfg
.project
.pydevproject
/.idea
/.venv
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

75 changes: 70 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,83 @@
# Changelog

# 7.2.2 (2018-05-10)

## 7.8.0(2022-06-08)
* 对象存储,管理类 API 发送请求时增加 [X-Qiniu-Date](https://developer.qiniu.com/kodo/3924/common-request-headers) (生成请求的时间) header

## 7.7.1 (2022-05-11)
* 对象存储,修复上传不制定 key 部分情况下会上传失败问题。

## 7.7.0 (2022-04-29)
* 对象存储,新增 set_object_lifecycle (设置 Object 生命周期) API

## 7.6.0 (2022-03-28)
* 优化了错误处理机制
* 支持 [Qiniu](https://developer.qiniu.com/kodo/1201/access-token) 签名算法

## 7.5.0 (2021-09-23)
* 上传策略新增对部分字段支持

## 7.4.1 (2021-05-25)
* 分片上传 v2 方法不再强制要求 bucket_name 参数

## 7.4.0 (2021-05-21)
* 支持分片上传 v2

## 7.3.1 (2021-01-06)
* 修复 ResponseInfo 对扩展码错误处理问题
* 增加 python v3.7,v3.8,v3.9 版本 CI 测试

## 7.3.0 (2020-09-23)
新增
* sms[云短信]:新增查询短信发送记录方法:get_messages_info
* cdn: 新增上线域名 domain_online 方法、下线域名 domain_offline 方法和删除域名 delete_domain 方法
* 对象存储:新增批量解冻build_batch_restoreAr方法、获取空间列表bucket_domain方法和修改空间访问权限change_bucket_permission方法

## 7.2.10 (2020-08-21)
* 修复上传策略中forceSaveKey参数没有签算进上传token,导致上传失败的问题
## 7.2.9 (2020-08-07)
* 支持指定本地ctx缓存文件.qiniu_pythonsdk_hostscache.json 文件路径
* 更正接口返回描述docstring
* 修复接口对非json response 处理
* ci 覆盖增加python 3.6 3.7
* 修复获取域名列方法
* 修复python3 环境下,二进制对象上传问题


## 7.2.8(2020-03-27)
* add restoreAr

## 7.2.7(2020-03-10)
* fix bucket_info

## 7.2.6(2019-06-26)
* 添加sms

## 7.2.5 (2019-06-06)
* 添加sms

## 7.2.4 (2019-04-01)
* 默认导入region类

## 7.2.3 (2019-02-25)
* 新增region类,zone继承
* 上传可以指定上传域名
* 新增上传指定上传空间和qvm指定上传内网的例子
* 新增列举账号空间,创建空间,查询空间信息,改变文件状态接口,并提供例子

## 7.2.2 (2018-05-10)
* 增加连麦rtc服务端API功能

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

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

# 7.1.8 (2017-10-18)
## 7.1.8 (2017-10-18)
* 恢复kirk的API为原来的状态

## 7.1.7 (2017-09-27)
Expand All @@ -35,7 +100,7 @@

## 7.1.2 (2017-03-24)
### 增加
* 增加设置文件生命周期的接口
* 增加设置文件生命周期的接口

## 7.1.1 (2017-02-03)
### 增加
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

[![@qiniu on weibo](http://img.shields.io/badge/weibo-%40qiniutek-blue.svg)](http://weibo.com/qiniutek)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
[![Build Status](https://travis-ci.org/qiniu/python-sdk.svg)](https://travis-ci.org/qiniu/python-sdk)
[![Build Status](https://github.com/qiniu/python-sdk/actions/workflows/ci-test.yml/badge.svg)](https://travis-ci.org/qiniu/python-sdk)
[![GitHub release](https://img.shields.io/github/v/tag/qiniu/python-sdk.svg?label=release)](https://github.com/qiniu/python-sdk/releases)
[![Latest Stable Version](https://img.shields.io/pypi/v/qiniu.svg)](https://pypi.python.org/pypi/qiniu)
[![Download Times](https://img.shields.io/pypi/dm/qiniu.svg)](https://pypi.python.org/pypi/qiniu)
[![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)
[![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)
[![Coverage Status](https://codecov.io/gh/qiniu/python-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/python-sdk)

## 安装

通过pip
Expand All @@ -17,10 +19,10 @@ $ pip install qiniu

## 运行环境

| Qiniu SDK版本 | Python 版本 |
|:--------------------:|:---------------------------:|
| 7.x | 2.6, 2.7, 3.3, 3.4, 3.5|
| 6.x | 2.6, 2.7 |
| Qiniu SDK版本 | Python 版本 |
| :-----------: | :------------------------------------: |
| 7.x | 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9 |
| 6.x | 2.7 |

## 使用方法

Expand All @@ -42,11 +44,6 @@ import qiniu

```
更多参见SDK使用指南: http://developer.qiniu.com/code/v7/sdk/python.html

### 命令行工具
安装完后附带有命令行工具,可以计算etag
```bash
$ qiniupy etag yourfile
```
## 测试
Expand All @@ -58,7 +55,7 @@ $ py.test
## 常见问题

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

## 代码贡献
Expand Down
1 change: 1 addition & 0 deletions examples/.qiniu_pythonsdk_hostscache.json
Original file line number Diff line number Diff line change
@@ -0,0 +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}}
3 changes: 3 additions & 0 deletions examples/batch_copy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
# flake8: noqa


"""
批量拷贝文件
Expand Down
2 changes: 2 additions & 0 deletions examples/batch_delete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# flake8: noqa

"""
批量删除文件
Expand Down
2 changes: 2 additions & 0 deletions examples/batch_move.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# flake8: noqa

"""
批量移动文件
Expand Down
2 changes: 2 additions & 0 deletions examples/batch_rename.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# flake8: noqa

"""
批量重命名文件
Expand Down
31 changes: 31 additions & 0 deletions examples/batch_restoreAr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# flake8: noqa

"""
批量解冻文件
https://developer.qiniu.com/kodo/api/1250/batch
"""

from qiniu import build_batch_restoreAr, Auth, BucketManager

# 七牛账号的公钥和私钥
access_key = '<access_key>'
secret_key = '<secret_key>'

q = Auth(access_key, secret_key)

bucket = BucketManager(q)

# 存储空间
bucket_name = "空间名"

# 字典的键为需要解冻的文件,值为解冻有效期1-7
ops = build_batch_restoreAr(bucket_name,
{"test00.png": 1,
"test01.jpeg": 2,
"test02.mp4": 3
}
)

ret, info = bucket.batch(ops)
print(info)
4 changes: 2 additions & 2 deletions examples/batch_stat.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
# flake8: noqa

"""
批量查询文件信息
https://developer.qiniu.com/kodo/api/1250/batch
"""


from qiniu import build_batch_stat, Auth, BucketManager

access_key = ''

secret_key = ''

q = Auth(access_key, secret_key)
Expand Down
24 changes: 24 additions & 0 deletions examples/bucket_domain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# flake8: noqa

from qiniu import Auth
from qiniu import BucketManager

"""
获取空间绑定的加速域名
https://developer.qiniu.com/kodo/api/3949/get-the-bucket-space-domain
"""

# 七牛账号的 公钥和私钥
access_key = '<access_key>'
secret_key = '<secret_key>'

# 空间名
bucket_name = ''

q = Auth(access_key, secret_key)

bucket = BucketManager(q)

ret, info = bucket.bucket_domain(bucket_name)
print(info)
19 changes: 19 additions & 0 deletions examples/bucket_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# flake8: noqa

from qiniu import Auth
from qiniu import BucketManager

# 需要填写你的 Access Key 和 Secret Key
access_key = ''
secret_key = ''

# 空间名
bucket_name = 'bucket_name'

q = Auth(access_key, secret_key)

bucket = BucketManager(q)

ret, info = bucket.bucket_info(bucket_name)
print(info)
2 changes: 2 additions & 0 deletions examples/cdn_bandwidth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# flake8: noqa

"""
查询指定域名指定时间段内的带宽
"""
Expand Down
2 changes: 2 additions & 0 deletions examples/cdn_flux.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# flake8: noqa

"""
查询指定域名指定时间段内的流量
"""
Expand Down
2 changes: 2 additions & 0 deletions examples/cdn_log.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# flake8: noqa

"""
获取指定域名指定时间内的日志链接
"""
Expand Down
22 changes: 22 additions & 0 deletions examples/change_bucket_permission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# flake8: noqa

from qiniu import Auth
from qiniu import BucketManager

# 需要填写七牛账号的 公钥和私钥
access_key = '<access_key>'
secret_key = '<secret_key>'

# 空间名
bucket_name = ""

# private 参数必须是str类型,0表示公有空间,1表示私有空间
private = "0"

q = Auth(access_key, secret_key)

bucket = BucketManager(q)

ret, info = bucket.change_bucket_permission(bucket_name, private)
print(info)
Loading

0 comments on commit 8a1e033

Please sign in to comment.