本文整理匯總了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