1
This commit is contained in:
parent
923263ad93
commit
e158715fa4
65
scripts/md_csv/test_gamelog.py
Normal file
65
scripts/md_csv/test_gamelog.py
Normal file
@ -0,0 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import json
|
||||
import pprint
|
||||
import hashlib
|
||||
import http.client
|
||||
import urllib.parse
|
||||
|
||||
GAMELOG_HOST = 'gamelog-dev.the7ys.com'
|
||||
|
||||
log_dict = json.loads(open('dict.json', 'r').read())
|
||||
str_keys = {'str' + str(i) : True for i in range(1, 40)}
|
||||
num_keys = {'num' + str(i) : True for i in range(1, 40)}
|
||||
|
||||
def genTestData(node):
|
||||
data = {}
|
||||
for key in node['__keys__']:
|
||||
if key in str_keys:
|
||||
data[key] = 'abcdef'
|
||||
elif key in num_keys:
|
||||
data[key] = 12345
|
||||
else:
|
||||
data[key] = 'xxxxx'
|
||||
return data
|
||||
|
||||
def md5Str(text):
|
||||
m1 = hashlib.md5()
|
||||
m1.update(text.encode('utf-8'))
|
||||
return m1.hexdigest()
|
||||
|
||||
def createSessionId(accountid, register_time, session_key):
|
||||
nowtime = register_time
|
||||
return nowtime + '_' + register_time + '_' + \
|
||||
md5Str(accountid + 'f3a6a9a5-217a-4079-ab99-b5d69b8212be' + register_time + nowtime) + '_' + \
|
||||
md5Str('f3a6a9a5-217a-4079-ab99-b5d69b8212be' + accountid + session_key)
|
||||
|
||||
def testReportLog():
|
||||
for key in log_dict['__keys__']:
|
||||
node = log_dict[key]
|
||||
strings = key.split('-')
|
||||
logclass1 = strings[0]
|
||||
logclass2 = strings[1]
|
||||
accountid = str(int(time.time()))
|
||||
url = '/webapp/index.php?c=GameLog&a=reportLog&' + '&'.join([
|
||||
'gameid=' + '1004',
|
||||
'channel=' + '6000',
|
||||
'localuuid=' + accountid,
|
||||
'account_id=' + accountid,
|
||||
'session_id=' + createSessionId(accountid, accountid, 'abdef'),
|
||||
'access_token=' + '',
|
||||
'from_appid=' + 'from_appid',
|
||||
'logclass1=' + logclass1,
|
||||
'logclass2=' + logclass2
|
||||
])
|
||||
post_body = genTestData(node)
|
||||
|
||||
conn = http.client.HTTPConnection(GAMELOG_HOST)
|
||||
conn.request("POST", url, json.dumps(post_body))
|
||||
data = conn.getresponse()
|
||||
print(data.read().decode('utf-8'))
|
||||
# print(json.loads(data.read().decode('utf-8')))
|
||||
|
||||
testReportLog()
|
Loading…
x
Reference in New Issue
Block a user