mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
refactor loading of SMTP action module in tests (deprecated load_module removed in v.3.15)
This commit is contained in:
parent
7528fce11b
commit
247667c9c2
1 changed files with 5 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ import threading
|
|||
import unittest
|
||||
import re
|
||||
import sys
|
||||
import types
|
||||
import importlib
|
||||
|
||||
from ..dummyjail import DummyJail
|
||||
|
|
@ -296,10 +297,11 @@ try:
|
|||
self.jail = DummyJail()
|
||||
pythonModule = os.path.join(CONFIG_DIR, "action.d", "smtp.py")
|
||||
pythonModuleName = os.path.basename(pythonModule.rstrip(".py"))
|
||||
customActionModule = importlib.machinery.SourceFileLoader(
|
||||
pythonModuleName, pythonModule).load_module()
|
||||
ldr = importlib.machinery.SourceFileLoader(pythonModuleName, pythonModule)
|
||||
mod = types.ModuleType(ldr.name)
|
||||
ldr.exec_module(mod)
|
||||
|
||||
self.action = customActionModule.Action(
|
||||
self.action = mod.Action(
|
||||
self.jail, "test", host="localhost:%i" % self.port)
|
||||
|
||||
self.action.ssl = True
|
||||
|
|
|
|||
Loading…
Reference in a new issue