mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
Use tempfile contextmanager in with_tmpdir
This commit is contained in:
parent
3c22ae161c
commit
5045f05107
1 changed files with 1 additions and 5 deletions
|
|
@ -235,12 +235,8 @@ def with_tmpdir(f):
|
|||
"""
|
||||
@wraps(f)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
tmp = tempfile.mkdtemp(prefix="f2b-temp")
|
||||
try:
|
||||
with tempfile.TemporaryDirectory(prefix="f2b-temp") as tmp:
|
||||
return f(self, tmp, *args, **kwargs)
|
||||
finally:
|
||||
# clean up
|
||||
shutil.rmtree(tmp)
|
||||
return wrapper
|
||||
|
||||
def with_alt_time(f):
|
||||
|
|
|
|||
Loading…
Reference in a new issue