本文整理汇总了Python中sanguo.Sanguo.close方法的典型用法代码示例。如果您正苦于以下问题:Python Sanguo.close方法的具体用法?Python Sanguo.close怎么用?Python Sanguo.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sanguo.Sanguo
的用法示例。
在下文中一共展示了Sanguo.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_weipai
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [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 close [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: do_zengzan
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def do_zengzan(self, nstr):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.zengzan(nstr)
sanguo.close()
if not data:
raise Exception()
return data
except:
logger.info('do_zengzan failed, will sleep 2 seconds')
time.sleep(2)
t += 1
示例4: suaxin_husong_list
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def suaxin_husong_list(self):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.husong_suaxin()
sanguo.close()
if not data:
raise Exception()
return data
except:
logger.info('husong_suaxin failed, will sleep %d seconds'%(t*2))
time.sleep(t*2)
t += 1
示例5: do_upgrade
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def do_upgrade(self, eid, magic, buymagic=0):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.upgradeEquip(eid, magic, buymagic)
sanguo.close()
if not data:
raise Exception()
logger.info('Upgrade %s succeed'%(eid))
return data
except:
time.sleep(2)
t += 1
示例6: tongsang
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def tongsang(uname):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.tongsang(uname)
sanguo.close()
if not data:
raise Exception()
logger.info("Tongsang %s succeed." % (uname))
return data
except:
time.sleep(3)
t += 1
示例7: get_user
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def get_user(uid):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.getUserInfo(uid)
sanguo.close()
if not data:
raise Exception()
else:
return data
except:
time.sleep(2)
t += 1
示例8: get_equip_info
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def get_equip_info(self):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.get_equip_info()
sanguo.close()
if not data:
raise Exception()
else:
return data
except:
time.sleep(2)
t += 1
示例9: bianzhen
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def bianzhen(self, keji):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.bianzhen(keji)
sanguo.close()
if not data:
logger.error('bianzhen failed, data None')
raise Exception()
return data
except:
logger.info('bianzhen failed, will sleep %d seconds'%(t*2))
time.sleep(t*2)
t += 1
示例10: sell_baowu
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def sell_baowu(bid):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.sell_baowu(bid)
sanguo.close()
if not data:
raise Exception()
logger.info("sell baowu %s succeed"%(str(bid)))
return data
except:
#logger.error("sell baowu %s failed"%(str(bid)))
time.sleep(2)
t += 1
示例11: do_ttt
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def do_ttt(self):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.tongtianta()
sanguo.close()
if not data:
logger.error('ttt failed, data None')
raise Exception()
logger.info('tongtianta succeed, result %d'%(data['result']))
return data
except:
logger.info('do_ttt failed, will sleep %d seconds'%(t*2))
time.sleep(t*2)
示例12: send_command
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def send_command(cmd, *args):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
function = getattr(sanguo, cmd)
res = function(*args)
sanguo.close()
if res == None:
raise Exception()
return res
except:
#logger.error(cmd + "\n" + traceback.format_exc())
time.sleep(2*t)
t += 1
示例13: get_user
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def get_user(uid):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.getUserInfo(uid)
sanguo.close()
if not data:
raise Exception()
if not data.has_key('protectTime'):
raise Exception('No protectTime')
return data
except:
time.sleep(2 * t)
t += 1
示例14: sync_time
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def sync_time():
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
stime = sanguo.login()
if not stime:
raise Exception()
ltime = int(time.time())
sanguo.close()
Server_Time = stime
Local_Server_Diff = ltime - stime
return (Server_Time, Local_Server_Diff)
except:
time.sleep(2)
t += 1
示例15: get_city_info
# 需要导入模块: from sanguo import Sanguo [as 别名]
# 或者: from sanguo.Sanguo import close [as 别名]
def get_city_info(self, cityid, zoneid):
retry = 10
t = 1
while t <= retry:
try:
sanguo = Sanguo()
sanguo.login()
data = sanguo.getCityInfo(cityid, zoneid)
sanguo.close()
if not data:
logger.error('get_city_info failed')
raise Exception()
else:
return data
except:
time.sleep(2)
t += 1