-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsyspce_engine.py
More file actions
46 lines (34 loc) · 1.13 KB
/
syspce_engine.py
File metadata and controls
46 lines (34 loc) · 1.13 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
37
38
39
40
41
42
43
44
45
46
import threading
import logging
from time import sleep
from syspce_message import *
log = logging.getLogger('sysmoncorrelator')
class Engine(threading.Thread):
def __init__(self, data_buffer_in, data_condition_in,
src, daemon):
threading.Thread.__init__(self)
self.data_buffer_in = data_buffer_in
self.data_condition_in = data_condition_in
self._running = False
self.name = ''
self.module_id = -1
self.origin = Module.ENGINE_MANAGER
self.src = src
self.daemon_ = daemon
def run(self):
self._running = True
self.do_action()
def send_message(self, content):
message = Message(self.data_buffer_in, self.data_condition_in)
message.send(MessageType.ALERT,
MessageSubType.DETECT,
self.module_id,
self.src,
self.origin,
[content])
def do_action(self):
# To be overridden
pass
def terminate(self):
self._running = False
log.debug("%s ending..." % (self.name))