From a03c0bcced49cdf750df35828aff3eed81113716 Mon Sep 17 00:00:00 2001 From: fffonion Date: Mon, 20 Jan 2014 22:27:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=9B=B4=E6=94=B9=E4=B8=BA240s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maclient_network.py | 3 +++ maclient_update.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/maclient_network.py b/maclient_network.py index 197467d..c2d1b27 100644 --- a/maclient_network.py +++ b/maclient_network.py @@ -231,6 +231,9 @@ def update_server(self, check_inspection_str): self.logger.error(du8('错误的密钥?')) raw_input() os._exit(1) + + def set_timeout(self, timeout): + self.ht.timeout = timeout def post(self, uri, postdata = '', usecookie = True, setcookie = True, extraheader = {'Cookie2': '$Version=1'}, noencrypt = False, savetraffic = False, no2ndkey = False):#no2ndkey only used in jp server header = {} diff --git a/maclient_update.py b/maclient_update.py index 4e52985..b94176f 100644 --- a/maclient_update.py +++ b/maclient_update.py @@ -50,6 +50,7 @@ def check_revision(loc, rev_tuple): def update_master(loc, need_update, poster): new_rev = [None, None] if need_update[0]: + poster.set_timeout(240) a, b = poster.post('masterdata/card/update', postdata = '%s&revision=0' % poster.cookie) resp = XML2Dict().fromstring(b.replace('&', '--').replace('--#', '&#')).response # 不替换会解析出错摔 cards = resp.body.master_data.master_card_data.card @@ -71,6 +72,7 @@ def update_master(loc, need_update, poster): new_rev[0] = resp.header.revision.card_rev save_revision(loc, cardrev = new_rev[0]) if need_update[1]: + poster.set_timeout(240) a, b = poster.post('masterdata/item/update', postdata = '%s&revision=0' % poster.cookie) resp = XML2Dict().fromstring(b).response itmes = resp.body.master_data.master_item_data.item_info @@ -87,4 +89,5 @@ def update_master(loc, need_update, poster): open(opath.join(getPATH0, 'db/item.%s.txt' % loc), 'w').write('\n'.join(strs)) new_rev[1] = resp.header.revision.item_rev save_revision(loc, itemrev = new_rev[1]) + poster.set_timeout(15)#rollback return new_rev