本文整理汇总了Python中sanguo.Sanguo.compose_data方法的典型用法代码示例。如果您正苦于以下问题:Python Sanguo.compose_data方法的具体用法?Python Sanguo.compose_data怎么用?Python Sanguo.compose_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sanguo.Sanguo
的用法示例。
在下文中一共展示了Sanguo.compose_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_weipai
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import compose_data [as 别名]
def do_weipai(self, tpe, level):
dicdata = {
'level' : str(level),
'op' : 1021,
'type' : str(tpe),
}
retry = 10
t = 1
while t <= retry:
try:
res = ''
sanguo = Sanguo()
sanguo.login()
sanguo.login()
data = sanguo.compose_data(dicdata)
sanguo.tcpClientSock.send(data)
#res += sanguo.tcpClientSock.recv(1024)
time.sleep(2)
res += sanguo.tcpClientSock.recv(4096)
if len(res) < 5:
raise Exception()
data = util.decode_data(res)
if not data or len(data) < 1:
logger.error('no data')
raise Exception()
sanguo.close()
if not data[0].has_key('exception'):
self.add_cost(tpe, level)
return data
except:
#logger.error(traceback.format_exc())
time.sleep(2)
t += 1
示例2: get_pozen_info
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import compose_data [as 别名]
def get_pozen_info(self, campaignid):
dicdata = {
'op' : 3001,
'campaignId' : int(campaignid)
}
retry = 10
t = 1
while t <= retry:
try:
res = ''
sanguo = Sanguo()
sanguo.login()
sanguo.login()
data = sanguo.compose_data(dicdata)
sanguo.tcpClientSock.send(data)
time.sleep(2)
res += sanguo.tcpClientSock.recv(4096)
if len(res) < 5:
raise Exception()
data = util.decode_data(res)
if not data or len(data) < 1:
logger.error('no data')
raise Exception()
sanguo.close()
return data[1]['armys']
except:
time.sleep(2)
t += 1
示例3: send_data
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import compose_data [as 别名]
def send_data(dicdata, check_key=None):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
sanguo.login()
data = sanguo.compose_data(dicdata)
sanguo.tcpClientSock.send(data)
res = sanguo.tcpClientSock.recv(4096)
data = sanguo.decode(res)
if check_key:
if not data.has_key(check_key):
raise Exception()
sanguo.close()
if not data:
raise Exception()
return data
except:
#logger.error(traceback.format_exc())
time.sleep(2)
t += 1