Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix & optimization #302

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions qcloud_cos/cos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ def delete_object(self, Bucket, Key, **kwargs):
method='DELETE',
url=url,
bucket=Bucket,
auth=CosS3Auth(self._conf, Key),
auth=CosS3Auth(self._conf, Key, params),
headers=headers,
params=params)
data = dict(**rt.headers)
Expand Down Expand Up @@ -2680,11 +2680,8 @@ def put_bucket_domain_certificate(self, Bucket, DomainCertificateConfiguration,
headers = mapped(kwargs)
headers['Content-MD5'] = get_md5(xml_config)
headers['Content-Type'] = 'application/xml'
# params = {'domaincertificate': ''}
# 目前 Domain Certificate API 不能使用 params 传递 query_string '?domaincertificate=',
# 只能将'?domaincertificate'拼接到url
params = {'domaincertificate': ''}
url = self._conf.uri(bucket=Bucket)
url += '?domaincertificate'
logger.info("put bucket domain certificate, url=:{url} ,headers=:{headers}".format(
url=url,
headers=headers))
Expand All @@ -2693,8 +2690,9 @@ def put_bucket_domain_certificate(self, Bucket, DomainCertificateConfiguration,
url=url,
bucket=Bucket,
data=xml_config,
auth=CosS3Auth(self._conf),
headers=headers)
auth=CosS3Auth(self._conf, params=params),
headers=headers,
params=params)
return None

def get_bucket_domain_certificate(self, Bucket, DomainName, **kwargs):
Expand All @@ -2715,12 +2713,8 @@ def get_bucket_domain_certificate(self, Bucket, DomainName, **kwargs):
)
"""
headers = mapped(kwargs)
# 目前 Domain Certificate API 不能使用 params 传递 query_string '?domaincertificate=',
# 只能将'?domaincertificate'拼接到url
# params = {'domaincertificate': '', 'domainname': DomainName}
params = {'domainname': DomainName}
params = {'domaincertificate': '', 'domainname': DomainName}
url = self._conf.uri(bucket=Bucket)
url += '?domaincertificate'
logger.info("get bucket domain certificate, url=:{url} ,headers=:{headers}".format(
url=url,
headers=headers))
Expand Down Expand Up @@ -2752,12 +2746,8 @@ def delete_bucket_domain_certificate(self, Bucket, DomainName, **kwargs):
)
"""
headers = mapped(kwargs)
# 目前 Domain Certificate API 不能使用 params 传递 query_string '?domaincertificate=',
# 只能将'?domaincertificate'拼接到url
# params = {'domaincertificate': '', 'domainname': DomainName}
params = {'domainname': DomainName}
params = {'domaincertificate': '', 'domainname': DomainName}
url = self._conf.uri(bucket=Bucket)
url += "?domaincertificate"
logger.info("delete bucket domain certificate, url=:{url} ,headers=:{headers}".format(
url=url,
headers=headers))
Expand Down
10 changes: 9 additions & 1 deletion qcloud_cos/resumable_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
import sys
import errno
import threading
import logging
import uuid
Expand Down Expand Up @@ -45,7 +46,14 @@ def __init__(self, cos_client, bucket, key, dest_filename, object_info, part_siz
self.__tmp_file = None

if not os.path.exists(self.__dump_record_dir):
os.makedirs(self.__dump_record_dir)
# 多进程并发情况下makedirs会出现冲突, 需要进行异常捕获
try:
os.makedirs(self.__dump_record_dir)
except OSError as e:
if e.errno != errno.EEXIST:
logger.error('os makedir error: dir: {0}, errno {1}'.format(self.__dump_record_dir), e.errno)
raise
pass
logger.debug('resumale downloader init finish, bucket: {0}, key: {1}'.format(bucket, key))

def start(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def long_description():


setup(
name='cos-python-sdk-v5',
name='cos_python_sdk_v5', # comply with PEP 625
version='1.9.34',
url='https://www.qcloud.com/',
license='MIT',
Expand Down