optionally store names taken from the configuration file to ease debugging
parent
f58781adad
commit
91b65d8e1e
|
@ -0,0 +1 @@
|
||||||
|
**/__pycache__/
|
|
@ -15,6 +15,9 @@ class Step(abc.ABC):
|
||||||
def setNextStep(self, obj):
|
def setNextStep(self, obj):
|
||||||
self.nextStep = obj
|
self.nextStep = obj
|
||||||
|
|
||||||
|
def setStepName(self, name):
|
||||||
|
self.stepName = name
|
||||||
|
|
||||||
class Filter(Step):
|
class Filter(Step):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
# pyruse is intended as a replacement to both fail2ban and epylog
|
# pyruse is intended as a replacement to both fail2ban and epylog
|
||||||
# Copyright © 2017–2018 Y. Gablin
|
# Copyright © 2017–2018 Y. Gablin
|
||||||
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
|
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
|
||||||
from pyruse import log, module
|
from pyruse import config, log, module
|
||||||
|
|
||||||
class Workflow:
|
class Workflow:
|
||||||
def __init__(self, actions):
|
def __init__(self, actions):
|
||||||
|
self._withDebug = config.Config().asMap().get("debug", False)
|
||||||
seen = {}
|
seen = {}
|
||||||
dangling = []
|
dangling = []
|
||||||
firstStep = None
|
firstStep = None
|
||||||
|
@ -28,11 +29,13 @@ class Workflow:
|
||||||
firstStep = None
|
firstStep = None
|
||||||
isPreviousDangling = False
|
isPreviousDangling = False
|
||||||
isThenCalled = False
|
isThenCalled = False
|
||||||
for step in actions[label]:
|
for stepNum, step in enumerate(actions[label]):
|
||||||
if isThenCalled:
|
if isThenCalled:
|
||||||
break
|
break
|
||||||
mod = module.get(step)
|
mod = module.get(step)
|
||||||
obj = mod.module
|
obj = mod.module
|
||||||
|
if self._withDebug:
|
||||||
|
obj.setStepName(label + '[' + str(stepNum) + ']')
|
||||||
if mod.thenRun:
|
if mod.thenRun:
|
||||||
(seen, dangling) = \
|
(seen, dangling) = \
|
||||||
self._branchToChain(obj.setNextStep, mod.thenRun, actions, seen, dangling)
|
self._branchToChain(obj.setNextStep, mod.thenRun, actions, seen, dangling)
|
||||||
|
|
Loading…
Reference in New Issue