阿里云文档中心的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处理的更多相关文章

  1. 阿里云 RDS for MySQL支持什么引擎

    问题:我们的服务器是买的是阿里云,mysql版本5.011 ,本地和服务器配置一样,在本地可以安装discuzX3.4,但是在服务器上却报错了,如下图: 找了半天,才知道阿里云RDS 支持的mysql ...

  2. 阿里云RDS for SQL Server使用的一些最佳实践

    了解RDS的概念 这也是第一条,也是最重要的一条,在使用某项产品和服务之前,首先要了解该产品或服务的功能与限制,就像你买一个冰箱或洗衣机,通常也只有在阅读完说明书之后才能利用起来它们的所以功能,以及使 ...

  3. 阿里云RDS的mysql数据库占用空间超过90%的处理

    阿里云RDS数据库最大支持2T,目前已经占用了90%,如果进行分库或者迁移比较麻烦,思路是找出占用空间过大的日志或不重要的文件进行删除操作 查询所有数据库占用磁盘空间大小的SQL语句: show bi ...

  4. 阿里云RDS上的一些概念性记录

    刚接触RDS,只能对RDS上的一些特性做一些笔记,方便记忆,以下为RDS上的内容摘录,取自官方文档 1 数据备份 可使用命令行或图形界面进行逻辑数据备份.仅限通过 RDS 管理控制台 或 OPEN A ...

  5. 【故障公告】升级阿里云 RDS SQL Server 实例故障经过

    昨天晚上,我们使用的阿里云 RDS SQL Server 2008 R2 实例突然出现持续 CPU 100% 问题,后来我们通过重启实例恢复了正常(详见故障公告).但是在恢复正常后发现了新问题,这台 ...

  6. 本地库还原至阿里云RDS服务器

    在此也感谢阿里云售后兄弟的支持.全文参考 https://help.aliyun.com/document_detail/95738.html? 1. 首先得要有个阿里云账号,已经购买RDS数据库(本 ...

  7. Zabbix 监控阿里云RDS

    简介 Zabbix 监控阿里云RDS数据库.主要通过阿里云提供的API来进行监控. 需要在阿里云获取“用户AccessKey”指定ID,进行RDS监控. 环境 服务:Zabbix 3.0.28.zab ...

  8. 强强联合 阿里云 RDS for SQL Server 与 金蝶 K/3 WISE 产品实现兼容适配

    强强联合 阿里云 RDS for SQL Server 与 金蝶 K/3 WISE 产品实现兼容适配,原K/3 WISE用户通过简单配置就可以无缝搭配RDS SQL Server使用,不需再费时费力自 ...

  9. 为更强大而生的开源关系型数据库来了!阿里云RDS for MySQL 8.0 正式上线!

    2019年5月29日15时,阿里云RDS for MySQL 8.0正式上线,使得阿里云成为紧跟社区步伐,发布MySQL最新版本的云厂商.RDS for MySQL 8.0 产品是阿里云推出的 MyS ...

随机推荐

  1. java application maven项目打自定义zip包

    1.配置pom.xml文件,添加build节点 <build> <!-- 输出的包名 --> <finalName>p2p</finalName> &l ...

  2. Git基本知识

    一,安装 Ubuntu安装git:sudo apt-get install git-core Centos安装git:yum install git-core 二,配置身份---在提交代码时可以辨别身 ...

  3. 安装hadoop1.2.1(参考hadoop实战第二版)

    准备: 安装jdk和ssh. 1. 官网下载hadoop1.2.1 hadoop-1.2.1.tar.gz http://hadoop.apache.org/releases.html 2. 解压到/ ...

  4. scrapy 让指定的spider执行指定的pipeline

    处理scrapy中包括多个pipeline时如何让spider执行制定的pipeline管道1:创建一个装饰器from scrapy.exceptions import DropItemimport ...

  5. vue-router基本概念及使用

    index.html: <!DOCTYPE html> <html> <head> <title></title> <meta cha ...

  6. 分布式锁--Redis小试牛刀

    参考文章: Redis分布式锁的正确实现方式 分布式锁看这篇就够了 在这两篇文章的指引下亲测 Redis分布式锁 引言 分布式系统一定会存在CAP权衡问题,所以才会出现分布式锁 什么是CAP理论? 为 ...

  7. jQuery1.11源码分析(2)-----Sizzle源码中的正则表达式[原创]

    看完了上篇,对Sizzle有了一个大致的了解,我们接下来就可以正式开始啃Sizzle的源码了.上来就讲matcher难度太大,先来点开胃菜,讲讲Sizzle中的各个正则表达式的作用吧(本来还想讲初始化 ...

  8. [转载]必须Mark!最佳HTML5应用开发工具推荐

    http://www.csdn.net/article/2014-04-25/2819503-10-html5-tools-worth-checking-out/2 摘要:HTML5自诞生以来,作为新 ...

  9. Javascript加速运动与减速运动

    加速运动,即一个物体运动时速度越来越快:减速运动,即一个物体运动时速度越来越慢.现在用Javascript来模拟这两个效果,原理就是用setInterval或setTimeout动态改变一个元素与另外 ...

  10. ASP.NET生成二维码

    下面使用ThoughtWorks.QRCode.dll这个类库,实现生成二维码 使用时需要增加:下面三个命名空间 using ThoughtWorks.QRCode.Codec; using Thou ...