-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvcr_sample_conf.py
29 lines (23 loc) · 1.03 KB
/
vcr_sample_conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
#coding=utf-8
#导入Python标准日志模块
import logging
import os
#从Python SDK导入VCR配置管理模块以及安全认证模块
from baidubce.bce_client_configuration import BceClientConfiguration
from baidubce.auth.bce_credentials import BceCredentials
#设置VcrClient的Host,Access Key ID和Secret Access Key
vcr_host = "vcr.bj.baidubce.com"
access_key_id = os.environ["BAIDU_ACCOUNT_ACCESS_KEY"]
secret_access_key = os.environ["BAIDU_ACCOUNT_SECRET_ACCESS_KEY"]
#设置日志文件的句柄和日志级别
logger = logging.getLogger('baidubce.http.bce_http_client')
fh = logging.FileHandler("sample.log")
fh.setLevel(logging.DEBUG)
#设置日志文件输出的顺序、结构和内容
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger.setLevel(logging.DEBUG)
logger.addHandler(fh)
#创建BceClientConfiguration
config = BceClientConfiguration(credentials=BceCredentials(access_key_id, secret_access_key), endpoint = 'vcr.bj.baidubce.com')