Skip to content

Commit 7d0762e

Browse files
authored
Change default language to en us (#20)
* Update client_profile.py * Add files via upload * Update README.md
1 parent 18e9fdb commit 7d0762e

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,8 @@ If there is a proxy in your environment, you need to set the system environment
7171
## Certificate issue
7272

7373
When you install Python 3.6 or above on macOS, you may encounter a certificate error: `Error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056).`. This is because that on macOS, Python no longer uses the system's default certificate and does not provide a certificate itself. When an HTTPS request is made, the certificate provided by the `certifi` library needs to be used, but the SDK does not support specifying it; therefore, you can only solve this problem by installing the certificate with the `/Applications/Python 3.6/Install Certificates.command` command.
74+
75+
# Update Notice
76+
77+
## Change default language
78+
After the latest version is released, the default language of the SDK will be set to en-US, which may affect the call results of the SDK. If you need to revert to the previous language setting, please refer to the content of `examples/cvm/v20170312/describe_zone_by_language.py` to reset the language.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- coding: utf-8 -*-
2+
import os
3+
4+
from tencentcloud.common import credential
5+
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
6+
from tencentcloud.cvm.v20170312 import cvm_client, models
7+
8+
from tencentcloud.common.profile.client_profile import ClientProfile
9+
from tencentcloud.common.profile.http_profile import HttpProfile
10+
11+
try:
12+
cred = credential.Credential(
13+
os.environ.get("TENCENTCLOUD_SECRET_ID"),
14+
os.environ.get("TENCENTCLOUD_SECRET_KEY"))
15+
16+
httpProfile = HttpProfile()
17+
httpProfile.endpoint = "cvm.tencentcloudapi.com"
18+
19+
clientProfile = ClientProfile()
20+
clientProfile.httpProfile = httpProfile
21+
client = cvm_client.CvmClient(cred, "ap-guangzhou", clientProfile)
22+
23+
req = models.DescribeZonesRequest()
24+
resp = client.DescribeZones(req)
25+
print(resp.to_json_string())
26+
# When using the default language en US, assert result
27+
if resp.TotalCount > 0:
28+
assert "Guangzhou" in resp.to_json_string(), "language=en-US not working"
29+
30+
# When changing the language to use zh CN, assert result
31+
clientProfile.language = "zh-CN"
32+
client = cvm_client.CvmClient(cred, "ap-guangzhou", clientProfile)
33+
req = models.DescribeZonesRequest()
34+
resp = client.DescribeZones(req)
35+
print(resp.to_json_string())
36+
if resp.TotalCount > 0:
37+
assert "广州" in resp.to_json_string(), "language=zh-CN not working"
38+
except TencentCloudSDKException as err:
39+
assert False, "unexpected request failure"

tencentcloud/common/profile/client_profile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class ClientProfile(object):
2121
unsignedPayload = False
2222

23-
def __init__(self, signMethod=None, httpProfile=None, language="zh-CN",
23+
def __init__(self, signMethod=None, httpProfile=None, language="en-US",
2424
disable_region_breaker=True, region_breaker_profile=None, request_client=None):
2525
"""SDK profile.
2626

0 commit comments

Comments
 (0)