python的scribe client

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python的scribe client相关的知识,希望对你有一定的参考价值。

在网上找了一个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的scribe client的主要内容,如果未能解决你的问题,请参考以下文章

scribe优化版

Scribe Java Twitter发布错误

Client / Server Interoperability Support Matrix for Different Oracle Versions (Doc ID 207303.1)(代码片段

typescript Scribe #Scribe #Functions #MoussaElAnnan

Scribe安装及配置方法

undefined reference to `VTT for scribe::thrift::scribeClient'