Skip to content

Commit 7b1b110

Browse files
committed
handling conflicts
2 parents fded1ce + f856db2 commit 7b1b110

File tree

8 files changed

+72
-20
lines changed

8 files changed

+72
-20
lines changed

CHANGELOG.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,47 @@
11
# Changelog
2-
# 7.2.8(2020-03-27)
2+
## 7.2.9 (2020-08-07)
3+
* 支持指定本地ctx缓存文件.qiniu_pythonsdk_hostscache.json 文件路径
4+
* 更正接口返回描述docstring
5+
* 修复接口对非json response 处理
6+
* ci 覆盖增加python 3.6 3.7
7+
* 修复获取域名列方法
8+
* 修复python3 环境下,二进制对象上传问题
9+
10+
11+
## 7.2.8(2020-03-27)
312
* add restoreAr
413

5-
# 7.2.7(2020-03-10)
14+
## 7.2.7(2020-03-10)
615
* fix bucket_info
716

8-
# 7.2.6(2019-06-26)
17+
## 7.2.6(2019-06-26)
918
* 添加sms
1019

11-
# 7.2.5 (2019-06-06)
20+
## 7.2.5 (2019-06-06)
1221
* 添加sms
1322

14-
# 7.2.4 (2019-04-01)
23+
## 7.2.4 (2019-04-01)
1524
* 默认导入region类
1625

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

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

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

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

35-
# 7.1.8 (2017-10-18)
44+
## 7.1.8 (2017-10-18)
3645
* 恢复kirk的API为原来的状态
3746

3847
## 7.1.7 (2017-09-27)

examples/get_domaininfo.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
4+
"""
5+
获取指定域名指定时间内的日志链接
6+
"""
7+
import qiniu
8+
from qiniu import DomainManager
9+
10+
11+
# 账户ak,sk
12+
access_key = ''
13+
secret_key = ''
14+
15+
auth = qiniu.Auth(access_key=access_key, secret_key=secret_key)
16+
domain_manager = DomainManager(auth)
17+
domain = ''
18+
ret, info = domain_manager.get_domain(domain)
19+
print(ret)
20+
print(info)

qiniu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# flake8: noqa
1111

12-
__version__ = '7.2.8'
12+
__version__ = '7.2.9'
1313

1414
from .auth import Auth, QiniuMacAuth
1515

qiniu/http.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,20 @@ def _put(url, data, files, auth, headers=None):
7272
return __return_wrapper(r)
7373

7474

75-
def _get(url, params, auth):
75+
def _get(url, params, auth, headers=None):
7676
if _session is None:
7777
_init()
7878
try:
79+
post_headers = _headers.copy()
80+
if headers is not None:
81+
for k, v in headers.items():
82+
post_headers.update({k: v})
7983
r = _session.get(
8084
url,
8185
params=params,
82-
auth=qiniu.auth.RequestsAuth(auth) if auth is not None else None,
86+
auth=auth,
8387
timeout=config.get_default('connection_timeout'),
84-
headers=_headers)
88+
headers=post_headers)
8589
except Exception as e:
8690
return None, ResponseInfo(None, e)
8791
return __return_wrapper(r)
@@ -108,10 +112,18 @@ def _post_with_auth(url, data, auth):
108112
return _post(url, data, None, qiniu.auth.RequestsAuth(auth))
109113

110114

115+
def _get_with_auth(url, data, auth):
116+
return _get(url, data, qiniu.auth.RequestsAuth(auth))
117+
118+
111119
def _post_with_auth_and_headers(url, data, auth, headers):
112120
return _post(url, data, None, qiniu.auth.RequestsAuth(auth), headers)
113121

114122

123+
def _get_with_auth_and_headers(url, data, auth, headers):
124+
return _get(url, data, qiniu.auth.RequestsAuth(auth), headers)
125+
126+
115127
def _post_with_qiniu_mac_and_headers(url, data, auth, headers):
116128
return _post(url, data, None, qiniu.auth.QiniuMacRequestsAuth(auth), headers)
117129

qiniu/services/cdn/manager.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def get_domain(self, name):
212212
- ResponseInfo 请求的Response信息
213213
"""
214214
url = '{0}/domain/{1}'.format(self.server, name)
215-
return self.__get(url, None)
215+
return self.__get(url)
216216

217217
def put_httpsconf(self, name, certid, forceHttps):
218218
"""
@@ -268,8 +268,9 @@ def __put(self, url, data=None):
268268
headers = {'Content-Type': 'application/json'}
269269
return http._put_with_auth_and_headers(url, data, self.auth, headers)
270270

271-
def __get(self, url, params):
272-
return http._get_with_qiniu_mac(url, params, self.auth)
271+
def __get(self, url, data=None):
272+
headers = {'Content-Type': 'application/json'}
273+
return http._get_with_auth_and_headers(url, data, self.auth, headers)
273274

274275

275276
def create_timestamp_anti_leech_url(host, file_name, query_string, encrypt_key, deadline):

qiniu/services/storage/bucket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def __post(self, url, data=None):
367367
return http._post_with_auth(url, data, self.auth)
368368

369369
def __get(self, url, params=None):
370-
return http._get(url, params, self.auth)
370+
return http._get_with_auth(url, params, self.auth)
371371

372372

373373
def _build_op(*args):

qiniu/services/storage/uploader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def put_data(
2828
一个dict变量,类似 {"hash": "<Hash string>", "key": "<Key string>"}
2929
一个ResponseInfo对象
3030
"""
31-
final_data = ''
31+
final_data = b''
3232
if hasattr(data, 'read'):
3333
while True:
3434
tmp_data = data.read(config._BLOCK_SIZE)

test_qiniu.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from qiniu import Auth, set_default, etag, PersistentFop, build_op, op_save, Zone
1313
from qiniu import put_data, put_file, put_stream
1414
from qiniu import BucketManager, build_batch_copy, build_batch_rename, build_batch_move, build_batch_stat, \
15-
build_batch_delete
15+
build_batch_delete,DomainManager
1616
from qiniu import urlsafe_base64_encode, urlsafe_base64_decode
1717

1818
from qiniu.compat import is_py2, is_py3, b
@@ -455,6 +455,16 @@ def test_large_size(self):
455455
remove_temp_file(localfile)
456456

457457

458+
class CdnTestCase(unittest.TestCase):
459+
q = Auth(access_key, secret_key)
460+
domain_manager = DomainManager(q)
461+
462+
def test_get_domain(self):
463+
ret, info = self.domain_manager.get_domain('pythonsdk.qiniu.io')
464+
print(info)
465+
assert info.status_code == 200
466+
467+
458468
class ReadWithoutSeek(object):
459469
def __init__(self, str):
460470
self.str = str

0 commit comments

Comments
 (0)