-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
36 lines (34 loc) · 1.07 KB
/
test.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
# -*- coding: utf-8 -*-
from urllib.request import urlopen
from urllib.parse import urlencode
import time
import random
# pressure test
if __name__ == "__main__":
while True:
content = ''
if random.random() < 0.4:
content += '#'
for i in range(3):
tmp = hex(random.randint(0, 255))[2:]
if len(tmp) == 1:
tmp = '0' + tmp
content += tmp
if random.random() < 0.1:
content += '#btm '
elif random.random() < 0.11:
content += '#top '
if random.random() < 0.2:
content += '#time' + str(random.randint(2, 20)) + ' '
WORDS = ("python", "jumble", "easy", "difficult", "answer",
"xylophone")
for i in range(random.randint(1, 3)):
content += ' ' + random.choice(WORDS)
try:
urlopen('http://127.0.0.1:5000/push?' +
urlencode({
'message': content
}))
except:
pass
time.sleep(0.1)