示例#1
0
print(struct.unpack_from('<h', bs, struct.calcsize('<2Bhi36shi5sbi26s')), '12')
print(struct.unpack_from('<i', bs, struct.calcsize('<2Bhi36shi5sbi26sh')),
      '13')
print(struct.unpack_from('<6s', bs, struct.calcsize('<2Bhi36shi5sbi26shi')),
      '14')
print(struct.unpack_from('<b', bs, struct.calcsize('<2Bhi36shi5sbi26shi6s')),
      struct.calcsize('<2Bhi36shi5sbi26shi6s'), '15')
print(struct.unpack_from('<q', bs, struct.calcsize('<2Bhi36shi5sbi26shi6sb')),
      struct.calcsize('<2Bhi36shi5sbi26shi6sb'), '16')

print(struct.unpack_from('<H', bs, struct.calcsize('<2Bhi36shi5sbi26shi6sbq')),
      '17')
print(
    struct.unpack_from('<i', bs, struct.calcsize('<2Bhi36shi5sbi26shi6sbqH')),
    '18')
print(
    struct.unpack_from('<6s', bs,
                       struct.calcsize('<2Bhi36shi5sbi26shi6sbqHi')), '18')
print(
    struct.unpack_from('<B', bs,
                       struct.calcsize('<2Bhi36shi5sbi26shi6sbqHi6s')), '19')
print(
    struct.unpack_from('<B', bs,
                       struct.calcsize('<2Bhi36shi5sbi26shi6sbqHi6sB')), '20')

from taobaotmcpy.messageio import reader

message = reader(bs)

print(message.content)
示例#2
0
文件: test.py 项目: seeker-jie/pytmc
# coding: utf-8

from binascii import *

from taobaotmcpy.messageio import reader

s = '020205002400000035363630303062392d626538382d343465612d383431632d6132613865333565373964300100060000005f5f6b696e640101000000310000'

message = reader(unhexlify(s))
print(message.token)
print(message.content)

_MAX_INTEGER = (1 << 32) - 1
_MAX_LONG = (1 << 64) - 1
_AVAILABLE_KEY_CHARS = list(range(0x21, 0x2f + 1)) + list(range(0x3a, 0x7e + 1))
_MAX_CHAR_BYTE = (1 << 8) - 1

print(_MAX_INTEGER)
print(_MAX_LONG)
print(_AVAILABLE_KEY_CHARS)
print(_MAX_CHAR_BYTE)
# coding: utf-8

import struct
from binascii import *

b = '020104000100000005002400000033346563376666632d666235362d343432612d626433392d6535356237333030356536640000'

# a = '02 01 0400 01000000 0500 24000000 33346563376666632d666235362d343432612d626433392d653535623733303035653664 0000'
a = '33346563376666632d666235362d343432612d626433392d653535623733303035653664'  # 72

querenlianjie = '020104000100000005002400000035346537386461382d643633362d343462622d623066652d3831396164323238343739330000'

bs = unhexlify(querenlianjie)

print len(bs)
print len(querenlianjie)

# b = Buffer(unhexlify(querenlianjie_))
# print b.read_int()

print struct.unpack('<2Bhihi36sh', bs)
print len(''.join([str(i) for i in struct.unpack('<2Bhihi36sh', bs)]))

from taobaotmcpy.messageio import reader

message = reader(bs)
print message
print message.protocol_version
print message.message_type
print message.token
示例#4
0
# coding: utf-8

from binascii import *

from taobaotmcpy.messageio import reader

s = '020205002400000035363630303062392d626538382d343465612d383431632d6132613865333565373964300100060000005f5f6b696e640101000000310000'

message = reader(unhexlify(s))
print message.token
print message.content

_MAX_INTEGER = (1 << 32) - 1
_MAX_LONG = (1 << 64) - 1
_AVAILABLE_KEY_CHARS = range(0x21, 0x2f + 1) + range(0x3a, 0x7e + 1)
_MAX_CHAR_BYTE = (1 << 8) - 1

print _MAX_INTEGER
print _MAX_LONG
print _AVAILABLE_KEY_CHARS
print _MAX_CHAR_BYTE