forked from DevoInc/python-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_elements_with_probability.py
More file actions
36 lines (29 loc) · 1.12 KB
/
random_elements_with_probability.py
File metadata and controls
36 lines (29 loc) · 1.12 KB
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
from devoutils.faker import SyslogFakeGenerator
from collections import OrderedDict
import random
from devo.sender import Sender
def get_choices():
"""Get dict with options and probability of be selected"""
return OrderedDict([("Failed", 0.5),
("Success", 0.2),
("Totally broken", 0.1),
("404", 0.1),
("500", 0.05),
("What?", 0.05)])
if __name__ == "__main__":
with open("./random_elements_with_probability.jinja2", 'r') as myfile:
template = myfile.read()
con = None
# This example need a sender con
# Example
# con = Sender(config="./config.yaml")
custom = {"choices": get_choices}
# If you remove simulation or set to false, data will be send
f = SyslogFakeGenerator(engine=con,
template=template,
simulation=True,
probability=100,
frequency=(1, 1),
providers=custom,
verbose=True)
f.start()