阿里云文档中心的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. 四、spring boot 1.5.4 日志管理

    spring boot日志默认采用logback进行输出,你可以对logback进行定制化,方法如下: 在resources文件夹下建立logback.xml配置文件 <?xml version ...

  2. $.AJAX参数提交及后台获取方式

    $.AJAX默认是get方式提交,所以你在后台只能用获取url参数的方式获取,可指定type为post更改提交方式: 在后台可通过Request["控件name/url参数key" ...

  3. Linux上printf命令的用法

    printf格式化输出 基本格式 printf [format] [文本1] [文本2] .. 常用格式替换符 %s 字符串 %f 浮点格式 %c ASCII字符,即显示对应参数的第一个字符 %d,% ...

  4. hdu 5385 The path

    http://acm.hdu.edu.cn/showproblem.php?pid=5385 题意: 给定一张n个点m条有向边的图,构造每条边的边权(边权为正整数),令d(x)表示1到x的最短路,使得 ...

  5. 使用mybatisgenerator 辅助工具逆向工程

    使用mybatisgenerator 辅助工具生成单表的dao层接口,mapper xml 文件以及实体类,复杂的还得人手动去编写哈...所以我也不觉得这玩意儿在项目简单情况下有什么鸟用... wha ...

  6. 干货:制作科研slide简明规范

  7. [iOS]@synthesize和@dynamic关键字

    首先讲@property, 这是iOS6以后出来的关键词. 用它声明一个属性之后, 编译器会自动给你生成setter和getter方法的声明以及实现还有一个以_xxx 的成员变量(xxx是你属性定义的 ...

  8. Repeater控件的分页实现

    本文讲解Repeater控件与PagedDataSource相结合实现其分页功能.PagedDataSource 类封装那些允许数据源控件(如 DataGrid.GridView)执行分页操作的属性. ...

  9. java7,java8 中HashMap和ConcurrentHashMap简介

    一:Java7 中的HashMap 结构: HashMap 里面是一个数组,然后数组中每个元素是一个单向链表.链表中每个元素称为一个Entry 实例,Entry 包含四个属性:key, value, ...

  10. 第12月第15天 mysqlx boost reswift

    1. INSTALL PLUGIN mysqlx SONAME 'mysqlx.so' https://yq.aliyun.com/articles/38288 2. boost boost::sha ...