python的scribe client
2016-02-05 11:55
351 查看
在网上找了一个python的scribe client使用方法
依赖的模块:
代码例子:
依赖的模块:
pip install facebook-scribe pip install thrift
代码例子:
#!/usr/bin/python import sys from scribe import scribe from thrift.transport import TTransport, TSocket from thrift.protocol import TBinaryProtocol category = "test_log" host = "127.0.0.1" port = "6666" message = "hello world\n" log_entry = scribe.LogEntry(category, message) socket = TSocket.TSocket(host=host, port=port) transport = TTransport.TFramedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(trans=transport, strictRead=False, strictWrite=False) client = scribe.Client(iprot=protocol, oprot=protocol) transport.open() result = client.Log(messages=[log_entry]) transport.close() if result == scribe.ResultCode.OK: sys.exit() elif result == scribe.ResultCode.TRY_LATER: print >> sys.stderr, "TRY_LATER" sys.exit(84) # 'T' else: sys.exit("Unknown error code.")
相关文章推荐
- python机器学习包mlxtend的安装和配置
- python_netcat
- Python装饰器学习(九步入门)
- IPython
- Python:logging日志模块
- Python调用(运行)外部程序
- 用 Python 开发网站自动化测试脚本
- 关于spark运行FP-growth算法报错com.esotericsoftware.kryo.KryoException
- python selenium --frame
- python selenium --命令之文字范本匹配
- python selenium --browser 操作
- python selenium --层级定位
- python selenium --调用js
- python selenium --滚动条处理
- python selenium ---键盘事件
- Python装饰器与面向切面编程
- python安装模块时报异常:Compression requires the (missing) zlib module
- python selenium --unittest 框架
- Python selenium -- cookie处理
- python selenium --鼠标事件