diff --git a/.travis.yml b/.travis.yml index 8cb6774a..663617fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,8 @@ deploy: provider: pypi distributions: sdist bdist_wheel user: dt3310321 - password: ********* + password: + secure: LoSq2wZPbXJ4DkYCQk6Oi0mI6iwhAiE6Xgyvl+Rv1geYqPTuI8ht7dps2ENHM2gj8JqhsZ7C5p/g9P6YuIBk0OTYKewHgHBnUAQwePzu0N1ofzJtJVoSbhW0aPeNfF6DxkTPscBGCHuMyHb/r/buHa3hLoJKxF0l50jEUugTJnP6Ms7a3oa7GaLIJ4QAKMZtLTN31iIcW40r2vVwH+J3JyCr/xeUhwT5/MlaN9c5lLjh7eUig2DA8/6DpqPOm+wV+cn6dh2w2I294cSRsUPJJla63g0YTYbPT9RKeC2D5GiyfqCYAEYzvKdlBJ5hCURh5rxrjOCGlde4Inq0uX6AMETOnvJhkvDMQ5cZ2sUKUy4BC021xvVBdQ44MFI5oGAGUIHbhsAs6wKwWo2ZvmJ5A2Oh0Ny6cx+PzGkZVN9afDUeiGQQcXvHFPw/oZrtQo/H8y8YsIQedBbHOY4RUnt/ID2xOOaZ50REIaGPZJq4hXGgggRh14bKcFcAH/DkiMiBi0bMRhxUOUI57T+4F5Jl5AdrZg/j3FjVn4Jv3Xcr/+N6Xp2QIttRkpa3XpE7N3378V7PKMlGQs0YFWGqDKR9hffMgDQ6qC+E7/OylmxIrOHv4545QCfVUuOhkq9v6IINc1XkKZ4r0GpNk33yr08lZ+jlsMKZvycBF5W2Yp8LWkM= on: tags: true branch: master diff --git a/qcloud_cos/cos_auth.py b/qcloud_cos/cos_auth.py index 96f6eaa2..f5c75479 100644 --- a/qcloud_cos/cos_auth.py +++ b/qcloud_cos/cos_auth.py @@ -50,7 +50,7 @@ def __call__(self, r): format_str = u"{method}\n{host}\n{params}\n{headers}\n".format( method=r.method.lower(), host=path, - params=urlencode(sorted(uri_params.items())).replace('+', '%20'), + params=urlencode(sorted(uri_params.items())).replace('+', '%20').replace('%7E', '~'), headers='&'.join(map(lambda tupl: "%s=%s" % (tupl[0], tupl[1]), sorted(headers.items()))) ) logger.debug("format str: " + format_str) diff --git a/qcloud_cos/cos_client.py b/qcloud_cos/cos_client.py index 9743debb..5cd81de0 100644 --- a/qcloud_cos/cos_client.py +++ b/qcloud_cos/cos_client.py @@ -185,8 +185,10 @@ def send_request(self, method, url, timeout=30, **kwargs): info['code'] = 'NoSuchResource' info['message'] = 'The Resource You Head Not Exist' info['resource'] = url - info['requestid'] = res.headers['x-cos-request-id'] - info['traceid'] = res.headers['x-cos-trace-id'] + if 'x-cos-request-id' in res.headers: + info['requestid'] = res.headers['x-cos-request-id'] + if 'x-cos-trace-id' in res.headers: + info['traceid'] = res.headers['x-cos-trace-id'] logger.error(info) raise CosServiceError(method, info, res.status_code) else: diff --git a/qcloud_cos/cos_comm.py b/qcloud_cos/cos_comm.py index 93e8833c..d1d30a45 100644 --- a/qcloud_cos/cos_comm.py +++ b/qcloud_cos/cos_comm.py @@ -146,6 +146,7 @@ def xml_to_dict(data, origin_str="", replace_str=""): xmlstr = xmlstr.replace("{http://www.qcloud.com/document/product/436/7751}", "") xmlstr = xmlstr.replace("{https://cloud.tencent.com/document/product/436}", "") xmlstr = xmlstr.replace("{http://doc.s3.amazonaws.com/2006-03-01}", "") + xmlstr = xmlstr.replace("{http://s3.amazonaws.com/doc/2006-03-01/}", "") xmlstr = xmlstr.replace("{http://www.w3.org/2001/XMLSchema-instance}", "") if origin_str: xmlstr = xmlstr.replace(origin_str, replace_str) diff --git a/qcloud_cos/cos_exception.py b/qcloud_cos/cos_exception.py index bb8c2dea..c6f08411 100644 --- a/qcloud_cos/cos_exception.py +++ b/qcloud_cos/cos_exception.py @@ -27,7 +27,10 @@ def digest_xml(data): msg['requestid'] = result[0].childNodes[0].nodeValue result = root.getElementsByTagName('TraceId') - msg['traceid'] = result[0].childNodes[0].nodeValue + if result: + msg['traceid'] = result[0].childNodes[0].nodeValue + else: + msg['traceid'] = 'Unknown' return msg except Exception as e: return "Response Error Msg Is INVALID"