阿里云 rds python sdk不支持python3处理
阿里云文档中心的python版本aliyun-python-sdk-rds不支持python3处理
问题:默认情况下文档中心的python版本只支持python2,不兼容python3版本
需要稍微修改源码即可
修改核心sdk包中文件aliyunsdkcore/profile/location_service.py第143行即可
修改方法
def find_product_domain_from_location_service(
self, region_id, service_code, endpoint_type): request = DescribeEndpointRequest(self.__service_product_name,
self.__service_version,
self.__service_action,
region_id,
service_code,
endpoint_type)
try:
content = request.get_content()
method = request.get_method() signer = getattr(self.__clinetRef, '_signer')
header, url = signer.sign(self.__service_region, request)
if self.__clinetRef.get_user_agent() is not None:
header['User-Agent'] = self.__clinetRef.get_user_agent()
header['x-sdk-client'] = 'python/2.0.0'
protocol = request.get_protocol_type()
response = HttpResponse(
self.__service_domain,
url,
method,
{} if header is None else header,
protocol,
content,
self.__clinetRef.get_port()) status, header, body = response.get_response_object() result = json.loads(body)
if status == 200:
endpoint = result.get('Endpoints').get('Endpoint')
if len(endpoint) <= 0:
return None
else:
return endpoint[0].get('Endpoint')
elif 400 <= status < 500:
# print "serviceCode=" + service_code + " get location error!
# code=" + result.get('Code') +", message =" +
# result.get('Message')
return None
elif status >= 500:
raise exs.ServerException(
result.get('Code'), result.get('Message'))
else:
raise exs.ClientException(
result.get('Code'), result.get('Message'))
except IOError:
raise exs.ClientException(
error_code.SDK_SERVER_UNREACHABLE,
error_msg.get_msg('SDK_SERVER_UNREACHABLE'))
except AttributeError:
raise exs.ClientException(
error_code.SDK_INVALID_REQUEST,
error_msg.get_msg('SDK_INVALID_REQUEST'))
源方法
修改后
def find_product_domain_from_location_service(
self, region_id, service_code, endpoint_type): request = DescribeEndpointRequest(self.__service_product_name,
self.__service_version,
self.__service_action,
region_id,
service_code,
endpoint_type)
try:
content = request.get_content()
method = request.get_method() signer = getattr(self.__clinetRef, '_signer')
header, url = signer.sign(self.__service_region, request)
if self.__clinetRef.get_user_agent() is not None:
header['User-Agent'] = self.__clinetRef.get_user_agent()
header['x-sdk-client'] = 'python/2.0.0'
protocol = request.get_protocol_type()
response = HttpResponse(
self.__service_domain,
url,
method,
{} if header is None else header,
protocol,
content,
self.__clinetRef.get_port()) status, header, body = response.get_response_object() result = json.loads(body.decode('utf-8'))
# 修改上面行内容
if status == 200:
endpoint = result.get('Endpoints').get('Endpoint')
if len(endpoint) <= 0:
return None
else:
return endpoint[0].get('Endpoint')
elif 400 <= status < 500:
# print "serviceCode=" + service_code + " get location error!
# code=" + result.get('Code') +", message =" +
# result.get('Message')
return None
elif status >= 500:
raise exs.ServerException(
result.get('Code'), result.get('Message'))
else:
raise exs.ClientException(
result.get('Code'), result.get('Message'))
except IOError:
raise exs.ClientException(
error_code.SDK_SERVER_UNREACHABLE,
error_msg.get_msg('SDK_SERVER_UNREACHABLE'))
except AttributeError:
raise exs.ClientException(
error_code.SDK_INVALID_REQUEST,
error_msg.get_msg('SDK_INVALID_REQUEST'))
修改后
json在loads转为对象的时候loads方法的参数需要为字符串格式,而request请求返回的response对象是bytes格式,故需要做下decode。
阿里云 rds python sdk不支持python3处理的更多相关文章
- 阿里云 RDS for MySQL支持什么引擎
问题:我们的服务器是买的是阿里云,mysql版本5.011 ,本地和服务器配置一样,在本地可以安装discuzX3.4,但是在服务器上却报错了,如下图: 找了半天,才知道阿里云RDS 支持的mysql ...
- 阿里云RDS for SQL Server使用的一些最佳实践
了解RDS的概念 这也是第一条,也是最重要的一条,在使用某项产品和服务之前,首先要了解该产品或服务的功能与限制,就像你买一个冰箱或洗衣机,通常也只有在阅读完说明书之后才能利用起来它们的所以功能,以及使 ...
- 阿里云RDS的mysql数据库占用空间超过90%的处理
阿里云RDS数据库最大支持2T,目前已经占用了90%,如果进行分库或者迁移比较麻烦,思路是找出占用空间过大的日志或不重要的文件进行删除操作 查询所有数据库占用磁盘空间大小的SQL语句: show bi ...
- 阿里云RDS上的一些概念性记录
刚接触RDS,只能对RDS上的一些特性做一些笔记,方便记忆,以下为RDS上的内容摘录,取自官方文档 1 数据备份 可使用命令行或图形界面进行逻辑数据备份.仅限通过 RDS 管理控制台 或 OPEN A ...
- 【故障公告】升级阿里云 RDS SQL Server 实例故障经过
昨天晚上,我们使用的阿里云 RDS SQL Server 2008 R2 实例突然出现持续 CPU 100% 问题,后来我们通过重启实例恢复了正常(详见故障公告).但是在恢复正常后发现了新问题,这台 ...
- 本地库还原至阿里云RDS服务器
在此也感谢阿里云售后兄弟的支持.全文参考 https://help.aliyun.com/document_detail/95738.html? 1. 首先得要有个阿里云账号,已经购买RDS数据库(本 ...
- Zabbix 监控阿里云RDS
简介 Zabbix 监控阿里云RDS数据库.主要通过阿里云提供的API来进行监控. 需要在阿里云获取“用户AccessKey”指定ID,进行RDS监控. 环境 服务:Zabbix 3.0.28.zab ...
- 强强联合 阿里云 RDS for SQL Server 与 金蝶 K/3 WISE 产品实现兼容适配
强强联合 阿里云 RDS for SQL Server 与 金蝶 K/3 WISE 产品实现兼容适配,原K/3 WISE用户通过简单配置就可以无缝搭配RDS SQL Server使用,不需再费时费力自 ...
- 为更强大而生的开源关系型数据库来了!阿里云RDS for MySQL 8.0 正式上线!
2019年5月29日15时,阿里云RDS for MySQL 8.0正式上线,使得阿里云成为紧跟社区步伐,发布MySQL最新版本的云厂商.RDS for MySQL 8.0 产品是阿里云推出的 MyS ...
随机推荐
- 【poj3415】 Common Substrings
http://poj.org/problem?id=3415 (题目链接) 题意 给定两个字符串 A 和 B,求长度不小于 k 的公共子串的个数(可以相同). Solution 后缀数组论文题... ...
- 【bzoj2001】 Hnoi2010—City 城市建设
http://www.lydsy.com/JudgeOnline/problem.php?id=2001 (题目链接) 题意 给出一张无向图,$m$组操作,每次修改一条边的权值,对于每次操作输出修改之 ...
- 【bzoj1006】 HNOI2008—神奇的国度
http://www.lydsy.com/JudgeOnline/problem.php?id=1006 (题目链接) 题意 求弦图的最小染色数. Solution 弦图,详情参见论文. 这里我写的加 ...
- 【bzoj2878】 Noi2012—迷失游乐园
http://www.lydsy.com/JudgeOnline/problem.php?id=2878 (题目链接) 题意 求基环树上以任意点为起点的简单路径期望长度. Solution 啊啊啊好丑 ...
- CodeForces 获得数据
针对程序的输出可以看见 CodeForces :当输入.输出超过一定字符,会隐藏内容 所以:分若干个程序进行输入数据的获取 1. ;i<=q;i++) { scanf("%ld%ld% ...
- string::replace
#include <string> #include <cctype> #include <algorithm> #include <iostream> ...
- 【CSS】定义元素的位置
CSS定义元素的位置html元素的position属性,有4个属性值,分别是static.relative.fixed.absolute static: 1.默认值,一般不显式设置为static 2. ...
- Java基础-IO流对象之压缩流(ZipOutputStream)与解压缩流(ZipInputStream)
Java基础-IO流对象之压缩流(ZipOutputStream)与解压缩流(ZipInputStream) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 之前我已经分享过很多的J ...
- webpack快速入门——CSS进阶:自动处理CSS3前缀
为了浏览器的兼容性,有时候我们必须加入-webkit,-ms,-o,-moz这些前缀.目的就是让我们写的页面在每个浏览器中都可以顺利运行. 1.安装 cnpm i postcss-loader aut ...
- Linux - awk 文本处理工具四
awk 常用示例 获取本机 IP 方式 /sbin/ifconfig |awk -v RS="Bcast:" '{print $NF}'|awk -F: '/addr/{print ...