This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate.py
executable file
·70 lines (60 loc) · 1.66 KB
/
generate.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/env python2
# -*- coding: utf-8 -*-
# <verb> <uri> <region> <date>
# GET /tariff/mobile moscow 2018-03-24T12:22:23
import sys
import os.path
import random
import datetime
import config
VERB = ['GET']
URI = [
'/',
# /internet
'/internet/options/',
'/internet/archive/',
'/internet/lte/',
# /tariffs
'/tariffs/simple/',
'/tariffs/just_calls/',
'/tariffs/tablet/',
'/tariffs/archive/'
# other
'/ad/autoextend',
'/ad/pay',
'/ad/wholeworld',
'/ad/bonus',
'/go/recharge',
'/go/sdd',
'/go/cinema',
]
REGION = [
'moscow', 'spb', 'astrakhan', 'volga', 'chukotka',
'krasnodar', 'dv', 'altay', 'belgorod', 'irkutsk',
'kursk', 'magadan', 'omsk', 'komi'
]
print 'START DATE:', datetime.datetime.fromtimestamp(config.DATE_START).strftime('%Y-%m-%dT%H:%M:%S')
print 'DAYS:', config.DAYS
def write_requests(number, tt):
dt = datetime.datetime.fromtimestamp(tt)
for i in range(0, number):
v = random.choice(VERB)
u = random.choice(URI)
r = random.choice(REGION)
s = "%s %s %s %s\n" % (v, u, r, dt.strftime('%Y-%m-%dT%H:%M:%S'),)
fh.write(s)
sec = 0
for day in range(0, config.DAYS):
dst = "".join([config.LFILE_FMT, str(day)])
if os.path.exists(dst):
print 'Skipping', dst, 'generation, file already exists..'
continue
print 'Generating', dst
with open(dst, 'w+') as fh:
day_sec = 0
while day_sec < 86400:
rps = random.randrange(config.RPS_MIN, config.RPS_MAX, config.RPS_STEP)
write_requests(rps, config.DATE_START + day_sec + sec)
day_sec += 1
sec += day_sec
print 'Done..'