-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
75 lines (65 loc) · 1.99 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
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
71
72
73
74
75
import json, csv
from os.path import join, isfile, splitext
from os import listdir
from sqlmodel import create_engine
from enigma.engine.database import del_db, init_db
from enigma.models.box import Box
from enigma.models.settings import Settings
from enigma.models.credlist import Credlist
from enigma.models.team import RvBTeam
from enigma.broker import RabbitMQ
boxes_path = './example_configs/boxes'
creds_path = './example_configs/creds'
if input('Reset DB? ').lower() == 'y':
del_db()
init_db()
#print('boxes')
boxes = []
ident = 1
for path in listdir(boxes_path):
if isfile(join(boxes_path, path)) and splitext(path)[-1].lower() == '.json':
with open(join(boxes_path, path), 'r') as f:
box = Box(
name=splitext(path)[0].lower(),
identifier=ident,
service_config=json.load(f)
)
boxes.append(box)
box.add_to_db()
ident = ident + 1
#print('credlists')
credlists = []
for path in listdir(creds_path):
if isfile(join(creds_path, path)) and splitext(path)[-1].lower() == '.csv':
with open(join(creds_path, path), 'r+') as f:
csvreader = csv.reader(f)
creds = {}
for row in csvreader:
creds.update({
row[0]: row[1]
})
credlist = Credlist(
name=splitext(path)[0].lower(),
creds=creds
)
credlists.append(credlist)
credlist.add_to_db()
#print('teams')
"""teams = []
for i in range(5):
team = RvBTeam(
name=f'coolteam{i+1}',
identifier=i+1,
services=Box.all_service_names(boxes)
)
teams.append(team)
team.add_to_db()"""
Settings(first_octets='10.10', sla_requirement=2)
while True:
cmd = input('Enter command: ')
with RabbitMQ() as rabbit:
rabbit.channel.basic_publish(
exchange='enigma',
routing_key='enigma.engine.cmd',
body=cmd
)