Skip to content

Commit 8ba6a25

Browse files
lewzylulewzylu(卢众意)
and
lewzylu(卢众意)
authored
update to 1.9.0.0 (#309)
Co-authored-by: lewzylu(卢众意) <[email protected]>
1 parent 9708e97 commit 8ba6a25

12 files changed

+361
-386
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
## 介绍
1212
_______
1313

14-
腾讯云COS命令行工具, 目前可以支持 Python2.6 与 Python2.7 以及 Python3.x
14+
腾讯云COS命令行工具, 最新版本支持Python3.x, 1.8.x版本支持Python2.6/Python2.7。
1515

1616
## 在 Docker 上使用
1717

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ COSCMD
1111
介绍
1212
_______
1313

14-
腾讯云COS命令行工具, 目前可以支持Python2.6与Python2.7以及Python3.x
14+
腾讯云COS命令行工具, 最新版本支持Python3.x, 1.8.x版本支持Python2.6/Python2.7
1515

1616
安装指南
1717
__________

UPGRADING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
Coscmd Upgrade Guide
2+
====================
3+
1.9.0.0
4+
--------------------
5+
- Compatible with and supports Python 3.11 and Python 3.12.
6+
- No longer supports Python 2.x.
7+
- Integrate the deleteobject interface with the Python SDK and fix the issue of deleting object with empty versionid.
8+
- Domain auto-switching is enabled by default. You can disable it by setting auto_switch_domain to false in the configuration file.
9+
210
====================
311
1.8.6.26 to 1.8.6.28
412
--------------------
513
- Add file size threshold when downloading folder
614
- Fix incorrect path when synchronizing files
715
- Delete the crc64 verification parameters when downloading
16+
817
====================
918
1.8.6.25 to 1.8.6.26
1019
--------------------

coscmd/cos_auth.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
# -*- coding: utf-8 -*-
22
import hmac
33
import time
4-
import urllib
54
import hashlib
65
import logging
76
import requests
8-
import sys
9-
from six.moves.urllib.parse import quote, urlparse, unquote, urlencode
7+
from urllib.parse import urlparse, urlencode, quote, unquote
108
from requests.auth import AuthBase
11-
12-
if sys.version > '3':
13-
from coscmd.cos_global import Version
14-
from coscmd.cos_comm import to_bytes
15-
else:
16-
from cos_global import Version
17-
from cos_comm import to_bytes
9+
from coscmd.cos_global import Version
10+
from coscmd.cos_comm import to_bytes
1811

1912
logger = logging.getLogger("coscmd")
2013

@@ -35,7 +28,8 @@ def __call__(self, r):
3528
tmp_r = {}
3629
rt = urlparse(uri)
3730
if rt.query != "" and ("&" in rt.query or '=' in rt.query):
38-
uri_params = dict(map(lambda s: s.lower().split('='), rt.query.split('&')))
31+
uri_params = dict(
32+
map(lambda s: s.lower().split('='), rt.query.split('&')))
3933
elif rt.query != "":
4034
uri_params = {rt.query: ""}
4135
else:
@@ -44,29 +38,36 @@ def __call__(self, r):
4438
tmp_r = r.headers
4539
r.headers = {}
4640
r.headers['Host'] = rt.netloc
47-
headers = dict([(k.lower(), quote(v).lower()) for k, v in r.headers.items()])
41+
headers = dict([(k.lower(), quote(v).lower())
42+
for k, v in r.headers.items()])
4843
format_str = "{method}\n{host}\n{params}\n{headers}\n".format(
4944
method=method.lower(),
5045
host=unquote(rt.path),
5146
params=urlencode(uri_params),
52-
headers='&'.join(map(lambda p: (lambda x, y: "%s=%s" % (x, y))(*p), sorted(headers.items())))
53-
)
47+
headers='&'.join(map(lambda p: (lambda x, y: "%s=%s" %
48+
(x, y))(*p), sorted(headers.items())))
49+
)
5450
start_sign_time = int(time.time())
55-
sign_time = "{bg_time};{ed_time}".format(bg_time=start_sign_time-60, ed_time=start_sign_time + self._expire)
51+
sign_time = "{bg_time};{ed_time}".format(
52+
bg_time=start_sign_time-60, ed_time=start_sign_time + self._expire)
5653
sha1 = hashlib.sha1()
5754
sha1.update(to_bytes(format_str))
5855

59-
str_to_sign = "sha1\n{time}\n{sha1}\n".format(time=sign_time, sha1=sha1.hexdigest())
56+
str_to_sign = "sha1\n{time}\n{sha1}\n".format(
57+
time=sign_time, sha1=sha1.hexdigest())
6058

61-
sign_key = hmac.new(to_bytes(self._secret_key), to_bytes(sign_time), hashlib.sha1).hexdigest()
62-
sign = hmac.new(to_bytes(sign_key), to_bytes(str_to_sign), hashlib.sha1).hexdigest()
59+
sign_key = hmac.new(to_bytes(self._secret_key), to_bytes(
60+
sign_time), hashlib.sha1).hexdigest()
61+
sign = hmac.new(to_bytes(sign_key), to_bytes(
62+
str_to_sign), hashlib.sha1).hexdigest()
6363
sign_tpl = "q-sign-algorithm=sha1&q-ak={ak}&q-sign-time={sign_time}&q-key-time={key_time}&q-header-list={headers}&q-url-param-list={params}&q-signature={sign}"
6464
r.headers = tmp_r
6565
r.headers['Authorization'] = sign_tpl.format(
6666
ak=self._access_id,
6767
sign_time=sign_time,
6868
key_time=sign_time,
69-
params=';'.join(sorted(map(lambda k: k.lower(), uri_params.keys()))),
69+
params=';'.join(
70+
sorted(map(lambda k: k.lower(), uri_params.keys()))),
7071
headers=';'.join(sorted(headers.keys())),
7172
sign=sign
7273
)

0 commit comments

Comments
 (0)