Skip to content

Commit

Permalink
更新数据库超时更改为240s
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Jan 20, 2014
1 parent 0686f57 commit a03c0bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions maclient_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
3 changes: 3 additions & 0 deletions maclient_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit a03c0bc

Please sign in to comment.