阿里云 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 ...
随机推荐
- BZOJ5093 [Lydsy1711月赛]图的价值 【第二类斯特林数 + NTT】
题目链接 BZOJ5093 题解 点之间是没有区别的,所以我们可以计算出一个点的所有贡献,然后乘上\(n\) 一个点可能向剩余的\(n - 1\)个点连边,那么就有 \[ans = 2^{{n - 1 ...
- Django入门项目实践(下)
5.设置应用程序的样式 安装django-bootstrap3. # untitled/untitled/settings.py # ··· INSTALLED_APPS = [ 'django.co ...
- 【CF706D】Vasiliy's Multiset Trie+贪心
题目大意:需要维护一种数据结构,支持以下三种操作:插入一个数,删除一个数,查询该数据结构中的数异或给定数的最大值. 题解:如果没有删除操作就是一个标准的 Trie 上贪心求最大异或和问题.现在需要支持 ...
- 14.会场安排问题(L4)
时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 学校的小礼堂每天都会有许多活动,有时间这些活动的计划时间会发生冲突,需要选择出一些活动进行举办.小刘的工作就是安排学校 ...
- C语言复习---打印菱形
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <math ...
- CString的头文件
CString的头文件:#include <atlstr.h>
- Linux命令(三)远程登录
- javascript私有静态成员
就私有静态成员而言,指的是成员具有如下属性:1.以同一个构造函数创建的所有对象共享该成员.2.构造函数外部不可访问该成员. //构造函数 var Gadget = (function(){ //静态变 ...
- kali的中文输入法-安装后无中文选项的解决办法
我在我实体电脑上安装了kali 本想安装个中文输入法但是有时候输入发中根本没有选择输入法的这一项.所以导致很别扭,之前在虚机上安装过没有问题但是挪到实体机上就是没有用的也是fcitx,这一度让我这个小 ...
- python3迭代器和生成器
1.手动访问迭代器中的元素 #要手动访问迭代器中的元素,可以使用next()函数 In [3]: with open('/etc/passwd') as f: ...: try: ...: while ...