當前位置: 首頁>>代碼示例>>Python>>正文


Python sanguo.Sanguo類代碼示例

本文整理匯總了Python中sanguo.Sanguo的典型用法代碼示例。如果您正苦於以下問題:Python Sanguo類的具體用法?Python Sanguo怎麽用?Python Sanguo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Sanguo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sync_time

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
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例2: send_command

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
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例3: get_pozen_info

 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
開發者ID:flaresky,項目名稱:fengyunsanguo-plugin,代碼行數:28,代碼來源:pozenThread.py

示例4: do_weipai

 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
開發者ID:flaresky,項目名稱:fengyunsanguo-plugin,代碼行數:33,代碼來源:pifeng.py

示例5: tongsang

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
開發者ID:flaresky,項目名稱:fengyunsanguo-plugin,代碼行數:16,代碼來源:tongsang.py

示例6: suaxin_husong_list

 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
開發者ID:flaresky,項目名稱:fengyunsanguo-plugin,代碼行數:16,代碼來源:lanjieThread.py

示例7: get_equip_info

 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
開發者ID:flaresky,項目名稱:fengyunsanguo-plugin,代碼行數:16,代碼來源:MagicInfo.py

示例8: do_zengzan

 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
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例9: do_upgrade

 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
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例10: get_user

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
開發者ID:flaresky,項目名稱:fengyunsanguo-plugin,代碼行數:16,代碼來源:getUserInfo.py

示例11: do_ttt

 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)
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例12: sell_baowu

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
開發者ID:flaresky,項目名稱:fengyunsanguo-plugin,代碼行數:17,代碼來源:sellBaowu.py

示例13: bianzhen

 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
開發者ID:flaresky,項目名稱:fengyunsanguo-plugin,代碼行數:17,代碼來源:pozenThread.py

示例14: get_user

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
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例15: get_city_info

 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
開發者ID:flaresky,項目名稱:fengyunsanguo-plugin,代碼行數:17,代碼來源:cityThread.py


注:本文中的sanguo.Sanguo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。