从cloud foundry dropsonde protobuf定义文件生成的编译python
dropsonde的Python项目详细描述
#用于python的cloud foundry dropsonde协议
从cloud foundry dropsonde protobuf定义文件生成的编译python。
[dropsonde协议](https://github.com/cloudfoundry/dropsonde-protocol) 在这里定义,这个repo提供“proto”编译的python和python3 模块。
##示例
标准protobuf文件引用如下。
`python from dropsonde.pb import envelope_pb2 from dropsonde.pb import error_pb2 from dropsonde.pb import http_pb2 from dropsonde.pb import log_pb2 from dropsonde.pb import metric_pb2 from dropsonde.pb import uuid_pb2 `
uuid protobuf类型相当神秘,因此包含了一个实用函数 用于将类型解析为uuid格式的字符串。
`python >>> from dropsonde.util import get_uuid_string >>> application_guid = { ... 'low': '12413561682238894606', ... 'high': '3611542221973970511' ... } >>> application_guid = get_uuid_string(**application_guid) >>> print(application_guid) 0ef23f83-94d4-45ac-e455-014268ec2103 >>> `
##开发
生成文件提供所有核心开发任务。
###安装环境
安装
这将
一。克隆dropsonde protobuf repo 一。安装python2的依赖项 一。安装python3的依赖项
###重构并编译protobuf文件
编译
这将
一。创建protobuf源文件的副本 一。重构源文件中的“import”指令以匹配所需的python包结构 一。在重构的源文件上运行“protoc”,并将生成的python代码输出到“dropsonde.pb”python包树中。
###测试
进行测试
这将
一。运行测试以确保导入有效 一。确保uuid转换工具正常工作
###清洁
清洁
这将
一。删除所有重构的protobuf文件 一。删除python2和python3的virtualenv环境
###套餐
制作包
这将只使用setup.py打包编译好的python文件
###构建
生成
这将
一。运行“克隆”任务 一。运行“编译”任务 一。运行“测试”任务 一。运行“package”任务
###展开
进行部署
这将
一。运行“清理”任务 一。运行“克隆”任务 一。运行“编译”任务 一。运行“测试”任务 一。运行python setup.py sdist upload以部署到pypi。