本文整理汇总了Python中thriftpy.protocol.cybin.write_val函数的典型用法代码示例。如果您正苦于以下问题:Python write_val函数的具体用法?Python write_val怎么用?Python write_val使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_val函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_i8
def test_write_i8():
b = TMemoryBuffer()
b = TCyBufferedTransport(b)
proto.write_val(b, TType.I08, 123)
b.flush()
assert "7b" == hexlify(b.getvalue())
示例2: test_byteswap_i16
def test_byteswap_i16():
i = 128
b = TCyMemoryBuffer()
proto.write_val(b, TType.I16, i)
b.flush()
v = proto.read_val(b, TType.I16)
assert v == i
示例3: test_write_i16
def test_write_i16():
b = TMemoryBuffer()
b = TCyBufferedTransport(b)
proto.write_val(b, TType.I16, 12345)
b.flush()
assert "30 39" == hexlify(b.getvalue())
示例4: test_write_i32
def test_write_i32():
b = TMemoryBuffer()
b = TCyBufferedTransport(b)
proto.write_val(b, TType.I32, 1234567890)
b.flush()
assert "49 96 02 d2" == hexlify(b.getvalue())
示例5: test_write_bool
def test_write_bool():
b = TMemoryBuffer()
b = TCyBufferedTransport(b)
proto.write_val(b, TType.BOOL, 1)
b.flush()
assert "01" == hexlify(b.getvalue())
示例6: serve
def serve():
server_sock = TServerSocket(host="127.0.0.1", port=9090)
server_sock.listen()
client = server_sock.accept()
t = TCyBufferedTransport(client)
proto.write_val(t, TType.STRING, val)
t.flush()
示例7: serve
def serve():
server_sock = TServerSocket(
unix_socket="./thriftpy_test.sock")
server_sock.listen()
client = server_sock.accept()
t = TCyBufferedTransport(client)
proto.write_val(t, TType.STRING, val)
t.flush()
示例8: test_skip_string
def test_skip_string():
b = TCyMemoryBuffer()
proto.write_val(b, TType.STRING, "hello world")
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.STRING)
assert 123 == proto.read_val(b, TType.I32)
示例9: test_skip_double
def test_skip_double():
b = TCyMemoryBuffer()
proto.write_val(b, TType.DOUBLE, 0.123425897)
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.DOUBLE)
assert 123 == proto.read_val(b, TType.I32)
示例10: test_skip_bool
def test_skip_bool():
b = TCyMemoryBuffer()
proto.write_val(b, TType.BOOL, 1)
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.BOOL)
assert 123 == proto.read_val(b, TType.I32)
示例11: test_skip_map
def test_skip_map():
b = TCyMemoryBuffer()
proto.write_val(b, TType.MAP, {"hello": 0.3456}, spec=(TType.STRING, TType.DOUBLE))
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.MAP)
assert 123 == proto.read_val(b, TType.I32)
示例12: test_skip_list
def test_skip_list():
b = TCyMemoryBuffer()
proto.write_val(b, TType.LIST, [5, 6, 7, 8, 9], spec=TType.I32)
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.LIST)
assert 123 == proto.read_val(b, TType.I32)
示例13: serve
def serve():
server_sock = TServerSocket(unix_socket=unix_sock)
server_sock.listen()
client = server_sock.accept()
t = TCyBufferedTransport(client)
proto.write_val(t, TType.STRING, val)
t.flush()
# wait for client to read
time.sleep(1)
示例14: test_write_string
def test_write_string():
b = TCyMemoryBuffer()
proto.write_val(b, TType.STRING, "hello world!")
b.flush()
assert "00 00 00 0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21" == hexlify(b.getvalue())
b = TCyMemoryBuffer()
proto.write_val(b, TType.STRING, u("你好世界"))
b.flush()
assert "00 00 00 0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c" == hexlify(b.getvalue())
示例15: test_skip_struct
def test_skip_struct():
b = TCyMemoryBuffer()
p = proto.TCyBinaryProtocol(b)
item = TItem(id=123, phones=["123456", "abcdef"])
p.write_struct(item)
p.write_message_end()
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.STRUCT)
assert 123 == proto.read_val(b, TType.I32)