-
Notifications
You must be signed in to change notification settings - Fork 13
/
generator.py
40 lines (33 loc) · 979 Bytes
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import time
import random
import requests
import database
def generate(local=False):
count = 10000
players = ['Nick', 'Mike', 'Ben', 'Ken', 'Jane', 'Kelly', 'Jack', 'Alex']
floors = [
'Underground', 'Ground', 'Fist', 'Second',
'TowerGround', 'TowerFirst', 'TowerSecond', 'TowerTop'
]
ts_now = int(time.time())
ts_2015_01_01 = 1420070400
data = []
for i in range(0, count):
item = {
'player': random.choice(players),
'floor': random.choice(floors),
'position': {
'x': random.randint(0, 17),
'y': random.randint(0, 10)
},
'ts': random.randint(ts_2015_01_01, ts_now)
}
if local:
database.put(item)
else:
data.append(item)
if not local:
return requests.post("http://localhost:5000/data", json=data)
if __name__ == '__main__':
resp = generate()
print resp.text