Skip to content

Commit 815ba00

Browse files
author
yuniszhang
committed
解决CI域名没有默认初始化问题
1 parent e04d307 commit 815ba00

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

qcloud_cos/cos_client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,9 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
9494
if (Scheme != u'http' and Scheme != u'https'):
9595
raise CosClientError('Scheme can be only set to http/https')
9696
self._scheme = Scheme
97-
98-
# 客户使用全球加速域名时,只会传endpoint不会传region。此时这样endpointCi和region同时为None,就会报错。
99-
if EndpointCi is not None:
100-
# 格式化ci的endpoint 不支持自定义域名的
101-
self._endpoint_ci = format_endpoint(EndpointCi, Region, u'ci.')
97+
98+
# 格式化ci的endpoint 不支持自定义域名的
99+
self._endpoint_ci = format_endpoint(EndpointCi, Region, u'ci.')
102100

103101
# 兼容(SecretId,SecretKey)以及(AccessId,AccessKey)
104102
if (SecretId and SecretKey):

qcloud_cos/cos_comm.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,18 @@ def format_values(data):
221221

222222

223223
def format_endpoint(endpoint, region, module=u'cos.'):
224-
"""格式化终端域名"""
225-
if not endpoint and not region:
224+
# 客户使用全球加速域名时,只会传endpoint不会传region。此时这样endpointCi和region同时为None,就会报错。
225+
if not endpoint and not region and module == u'cos.':
226226
raise CosClientError("Region or Endpoint is required not empty!")
227-
if not endpoint:
227+
228+
"""格式化终端域名"""
229+
if endpoint:
230+
return to_unicode(endpoint)
231+
elif region:
228232
region = format_region(region, module)
229233
return u"{region}.myqcloud.com".format(region=region)
230234
else:
231-
return to_unicode(endpoint)
235+
return None
232236

233237

234238
def format_region(region, module=u'cos.'):

0 commit comments

Comments
 (0)