Skip to content

Commit 035e306

Browse files
author
wallisyan
authored
Merge pull request #256 from aliyun/refactor4.test
Refactor4.test
2 parents bca7b39 + a13cffa commit 035e306

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+458
-444
lines changed

aliyun-python-sdk-core/alibabacloud/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
# Copyright 2019 Alibaba Cloud Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
import logging
216

317

418
class NullHandler(logging.Handler):
19+
520
def emit(self, record):
621
pass
722

aliyun-python-sdk-core/alibabacloud/client.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
1415
import os
1516
import time
1617
from alibabacloud.handlers import RequestContext
1718
from alibabacloud.handlers.prepare_handler import PrepareHandler
1819
from alibabacloud.handlers.credentials_handler import CredentialsHandler
1920
from alibabacloud.handlers.signer_handler import SignerHandler
20-
2121
from alibabacloud.handlers.timeout_config_reader import TimeoutConfigReader
2222
from alibabacloud.handlers.endpoint_handler import EndpointHandler
2323
from alibabacloud.handlers.log_handler import LogHandler
@@ -36,8 +36,8 @@
3636
LogHandler(),
3737
EndpointHandler(),
3838
RetryHandler(),
39-
ServerErrorHandler(),
4039
HttpHandler(),
40+
ServerErrorHandler(),
4141
]
4242

4343
DEFAULT_FORMAT = 'JSON'
@@ -131,9 +131,9 @@ def read_from_profile(self):
131131

132132
else:
133133
profile = load_config(self.config_file)
134-
134+
135135
for key in dir(self):
136-
if profile.get(key)is not None and getattr(self, key) is None:
136+
if profile.get(key) is not None and getattr(self, key) is None:
137137
# 不存在config当中的值 pass
138138
setattr(self, key, profile.get(key))
139139
# print('不存在config当中的值', key)
@@ -180,7 +180,9 @@ def __init__(self, client_config, credentials_provider):
180180
self.logger = None # TODO initialize
181181
from alibabacloud.endpoint.default_endpoint_resolver import DefaultEndpointResolver
182182

183-
self.endpoint_resolver = DefaultEndpointResolver(self.config) # TODO initialize
183+
self.endpoint_resolver = DefaultEndpointResolver(self.config,
184+
self.credentials_provider)
185+
# TODO initialize
184186
# retry
185187
if self.config.enable_retry:
186188
self.retry_policy = retry_policy.get_default_retry_policy(

aliyun-python-sdk-core/alibabacloud/compat.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1+
# Copyright 2019 Alibaba Cloud Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
import sys
16+
217
from alibabacloud.vendored import six
318

419
if six.PY2:

aliyun-python-sdk-core/alibabacloud/credentials/provider.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2019 Alibaba Cloud Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
import json
216
import os
317
import time
@@ -32,7 +46,6 @@ def __init__(self):
3246
self._cached_credentials = None
3347

3448
def provide(self):
35-
3649
return self._cached_credentials
3750

3851

aliyun-python-sdk-core/alibabacloud/endpoint/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
#
1817

1918

2019
class EndpointResolver(object):

aliyun-python-sdk-core/alibabacloud/endpoint/chained_endpoint_resolver.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
# Licensed to the Apache Software Foundation (ASF) under one
32
# or more contributor license agreements. See the NOTICE file
43
# distributed with self work for additional information
@@ -15,12 +14,10 @@
1514
# KIND, either express or implied. See the License for the
1615
# specific language governing permissions and limitations
1716
# under the License.
18-
#
1917

2018
from alibabacloud.exceptions import ClientException
2119
from alibabacloud.endpoint import EndpointResolver
2220

23-
import aliyunsdkcore.acs_exception.error_code as error_code
2421
import aliyunsdkcore.acs_exception.error_msg as error_msg
2522

2623

@@ -36,7 +33,6 @@ def _check_product_code(self, request):
3633
return
3734

3835
raise ClientException(
39-
error_code.SDK_ENDPOINT_RESOLVING_ERROR,
4036
error_msg.ENDPOINT_NO_PRODUCT.format(
4137
product_code=request.product_code)
4238
)
@@ -47,7 +43,6 @@ def _check_region_id(self, request):
4743
return
4844

4945
raise ClientException(
50-
error_code.SDK_ENDPOINT_RESOLVING_ERROR,
5146
error_msg.INVALID_REGION_ID.format(region_id=request.region_id)
5247
)
5348

@@ -73,7 +68,6 @@ def resolve(self, request):
7368
self._check_region_id(request)
7469

7570
raise ClientException(
76-
error_code.SDK_ENDPOINT_RESOLVING_ERROR,
7771
error_msg.ENDPOINT_NO_REGION.format(
7872
region_id=request.region_id,
7973
product_code=request.product_code,

aliyun-python-sdk-core/alibabacloud/endpoint/default_endpoint_resolver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DefaultEndpointResolver(EndpointResolver):
2929
# Not recommended
3030
predefined_endpoint_resolver = UserCustomizedEndpointResolver()
3131

32-
def __init__(self, config, user_config=None):
32+
def __init__(self, config, credentials_provider, user_config=None):
3333

3434
self._user_customized_endpoint_resolver = UserCustomizedEndpointResolver()
3535

@@ -38,7 +38,7 @@ def __init__(self, config, user_config=None):
3838
self._user_customized_endpoint_resolver,
3939
LocalConfigRegionalEndpointResolver(user_config),
4040
LocalConfigGlobalEndpointResolver(user_config),
41-
LocationServiceEndpointResolver(config),
41+
LocationServiceEndpointResolver(config, credentials_provider),
4242
]
4343

4444
self._resolver = ChainedEndpointResolver(endpoint_resolvers)

aliyun-python-sdk-core/alibabacloud/endpoint/endpoint_resolver_base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
# Licensed to the Apache Software Foundation (ASF) under one
32
# or more contributor license agreements. See the NOTICE file
43
# distributed with self work for additional information
@@ -15,7 +14,6 @@
1514
# KIND, either express or implied. See the License for the
1615
# specific language governing permissions and limitations
1716
# under the License.
18-
#
1917

2018
from alibabacloud.endpoint import EndpointResolver
2119

aliyun-python-sdk-core/alibabacloud/endpoint/local_config_global_endpoint_resolver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
# Licensed to the Apache Software Foundation (ASF) under one
32
# or more contributor license agreements. See the NOTICE file
43
# distributed with self work for additional information
@@ -15,7 +14,7 @@
1514
# KIND, either express or implied. See the License for the
1615
# specific language governing permissions and limitations
1716
# under the License.
18-
#
17+
1918
from alibabacloud.vendored.six import iteritems
2019

2120
from alibabacloud.endpoint.local_config_regional_endpoint_resolver \
@@ -35,7 +34,8 @@ def _init_global_endpoint_data(self, obj):
3534

3635
global_endpoints = obj["global_endpoints"]
3736
for location_service_code, endpoint in iteritems(global_endpoints):
38-
self.put_endpoint_entry(self._make_endpoint_entry_key(location_service_code), endpoint)
37+
self.put_endpoint_entry(self._make_endpoint_entry_key(location_service_code),
38+
endpoint)
3939

4040
def resolve(self, request):
4141
if request.is_open_api_endpoint() and self.is_region_id_valid(request):

aliyun-python-sdk-core/alibabacloud/endpoint/local_config_regional_endpoint_resolver.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#
21
# Licensed to the Apache Software Foundation (ASF) under one
32
# or more contributor license agreements. See the NOTICE file
43
# distributed with self work for additional information
@@ -15,7 +14,6 @@
1514
# KIND, either express or implied. See the License for the
1615
# specific language governing permissions and limitations
1716
# under the License.
18-
#
1917

2018
import os.path
2119
import json
@@ -53,7 +51,8 @@ def _init_regional_endpoint_data(self, obj):
5351
self._regional_endpoint_data = obj["regional_endpoints"]
5452
for code, product_data in iteritems(obj["regional_endpoints"]):
5553
for region_id, endpoint in iteritems(product_data):
56-
self.put_endpoint_entry(self._make_endpoint_entry_key(code, region_id), endpoint)
54+
self.put_endpoint_entry(self._make_endpoint_entry_key(code, region_id),
55+
endpoint)
5756

5857
def _init_region_ids(self, obj):
5958
if "regions" not in obj:
@@ -82,7 +81,8 @@ def resolve(self, request):
8281
return None
8382

8483
def get_endpoint_key_from_request(self, request):
85-
return self._make_endpoint_entry_key(request.product_code.lower(), request.region_id.lower())
84+
return self._make_endpoint_entry_key(request.product_code.lower(),
85+
request.region_id.lower())
8686

8787
def _make_endpoint_entry_key(self, product_code, region_id):
8888
return self._get_normalized_product_code(product_code) + "." + region_id
@@ -103,7 +103,6 @@ def is_product_code_valid(self, request):
103103
request.region_id,
104104
self._get_normalized_product_code(request.product_code),
105105
request.location_service_code,
106-
request.endpoint_type,
107-
request.credentials_provider
106+
request.endpoint_type
108107
)
109108
return EndpointResolverBase.is_product_code_valid(self, tmp_request)

0 commit comments

Comments
 (0)