diff --git a/fail2ban/client/configparserinc.py b/fail2ban/client/configparserinc.py index 387f0f2c..5a3b60eb 100644 --- a/fail2ban/client/configparserinc.py +++ b/fail2ban/client/configparserinc.py @@ -24,7 +24,8 @@ __author__ = 'Yaroslav Halhenko' __copyright__ = 'Copyright (c) 2007 Yaroslav Halchenko' __license__ = 'GPL' -import os, sys +import os +import sys from ..helpers import getLogger if sys.version_info >= (3,2): # pragma: no cover diff --git a/fail2ban/client/configreader.py b/fail2ban/client/configreader.py index ed1fbcde..d86d6785 100644 --- a/fail2ban/client/configreader.py +++ b/fail2ban/client/configreader.py @@ -24,7 +24,8 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import glob, os +import glob +import os from ConfigParser import NoOptionError, NoSectionError from .configparserinc import SafeConfigParserWithIncludes, logLevel diff --git a/fail2ban/client/csocket.py b/fail2ban/client/csocket.py index 921b0de5..86d84a4d 100644 --- a/fail2ban/client/csocket.py +++ b/fail2ban/client/csocket.py @@ -26,7 +26,8 @@ __license__ = "GPL" #from cPickle import dumps, loads, HIGHEST_PROTOCOL from pickle import dumps, loads, HIGHEST_PROTOCOL -import socket, sys +import socket +import sys if sys.version_info >= (3,): # b"" causes SyntaxError in python <= 2.5, so below implements equivalent diff --git a/fail2ban/client/filterreader.py b/fail2ban/client/filterreader.py index debd4e28..8aae0c85 100644 --- a/fail2ban/client/filterreader.py +++ b/fail2ban/client/filterreader.py @@ -24,7 +24,8 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import os, shlex +import os +import shlex from .configreader import DefinitionInitConfigReader from ..server.action import CommandAction diff --git a/fail2ban/client/jailreader.py b/fail2ban/client/jailreader.py index 340508c0..f1b1783e 100644 --- a/fail2ban/client/jailreader.py +++ b/fail2ban/client/jailreader.py @@ -24,8 +24,10 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import re, glob, os.path +import glob import json +import os.path +import re from .configreader import ConfigReaderUnshared, ConfigReader from .filterreader import FilterReader diff --git a/fail2ban/server/action.py b/fail2ban/server/action.py index 8e0cd97f..58c064da 100644 --- a/fail2ban/server/action.py +++ b/fail2ban/server/action.py @@ -21,8 +21,14 @@ __author__ = "Cyril Jaquier and Fail2Ban Contributors" __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2011-2012 Yaroslav Halchenko" __license__ = "GPL" -import logging, os, subprocess, time, signal, tempfile -import threading, re +import logging +import os +import re +import signal +import subprocess +import tempfile +import threading +import time from abc import ABCMeta from collections import MutableMapping @@ -516,10 +522,10 @@ class CommandAction(ActionBase): realCmd = self.replaceTag(cmd, aInfo) else: realCmd = cmd - + # Replace static fields realCmd = self.replaceTag(realCmd, self._properties) - + return self.executeCmd(realCmd, self.timeout) @staticmethod @@ -549,7 +555,7 @@ class CommandAction(ActionBase): if not realCmd: logSys.debug("Nothing to do") return True - + _cmd_lock.acquire() try: # Try wrapped within another try needed for python version < 2.5 stdout = tempfile.TemporaryFile(suffix=".stdout", prefix="fai2ban_") @@ -602,4 +608,4 @@ class CommandAction(ActionBase): % (retcode, msg % locals())) return False raise RuntimeError("Command execution failed: %s" % realCmd) - + diff --git a/fail2ban/server/actions.py b/fail2ban/server/actions.py index 3a1c9579..95161290 100644 --- a/fail2ban/server/actions.py +++ b/fail2ban/server/actions.py @@ -24,9 +24,10 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import time, logging +import logging import os import sys +import time if sys.version_info >= (3, 3): import importlib.machinery else: diff --git a/fail2ban/server/asyncserver.py b/fail2ban/server/asyncserver.py index 8f5423b9..8ca86cfd 100644 --- a/fail2ban/server/asyncserver.py +++ b/fail2ban/server/asyncserver.py @@ -25,7 +25,13 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" from pickle import dumps, loads, HIGHEST_PROTOCOL -import asyncore, asynchat, socket, os, sys, traceback, fcntl +import asynchat +import asyncore +import fcntl +import os +import socket +import sys +import traceback from ..helpers import getLogger,formatExceptionInfo diff --git a/fail2ban/server/database.py b/fail2ban/server/database.py index 3ce3b2c0..63f4e1c9 100644 --- a/fail2ban/server/database.py +++ b/fail2ban/server/database.py @@ -21,11 +21,12 @@ __author__ = "Steven Hiscocks" __copyright__ = "Copyright (c) 2013 Steven Hiscocks" __license__ = "GPL" -import sys -import shutil, time -import sqlite3 import json import locale +import shutil +import sqlite3 +import sys +import time from functools import wraps from threading import RLock diff --git a/fail2ban/server/failregex.py b/fail2ban/server/failregex.py index 28ee8ef5..034d6877 100644 --- a/fail2ban/server/failregex.py +++ b/fail2ban/server/failregex.py @@ -21,7 +21,9 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import re, sre_constants, sys +import re +import sre_constants +import sys ## # Regular expression class. diff --git a/fail2ban/server/filter.py b/fail2ban/server/filter.py index cf0c0e2b..59070911 100644 --- a/fail2ban/server/filter.py +++ b/fail2ban/server/filter.py @@ -21,7 +21,12 @@ __author__ = "Cyril Jaquier and Fail2Ban Contributors" __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2011-2013 Yaroslav Halchenko" __license__ = "GPL" -import re, os, fcntl, sys, locale, codecs +import codecs +import fcntl +import locale +import os +import re +import sys from .failmanager import FailManagerEmpty, FailManager from .ticket import FailTicket @@ -839,7 +844,8 @@ class JournalFilter(Filter): # pragma: systemd no cover # This class contains only static methods used to handle DNS and IP # addresses. -import socket, struct +import socket +import struct class DNSUtils: diff --git a/fail2ban/server/filtergamin.py b/fail2ban/server/filtergamin.py index c9e8e31c..ac1fdf27 100644 --- a/fail2ban/server/filtergamin.py +++ b/fail2ban/server/filtergamin.py @@ -23,7 +23,8 @@ __author__ = "Cyril Jaquier, Yaroslav Halchenko" __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2012 Yaroslav Halchenko" __license__ = "GPL" -import time, fcntl +import fcntl +import time import gamin diff --git a/fail2ban/server/filterpoll.py b/fail2ban/server/filterpoll.py index f37be431..2f3f3203 100644 --- a/fail2ban/server/filterpoll.py +++ b/fail2ban/server/filterpoll.py @@ -24,7 +24,8 @@ __author__ = "Cyril Jaquier, Yaroslav Halchenko" __copyright__ = "Copyright (c) 2004 Cyril Jaquier; 2012 Yaroslav Halchenko" __license__ = "GPL" -import time, os +import os +import time from .failmanager import FailManagerEmpty from .filter import FileFilter diff --git a/fail2ban/server/filtersystemd.py b/fail2ban/server/filtersystemd.py index d1150c57..105c2623 100644 --- a/fail2ban/server/filtersystemd.py +++ b/fail2ban/server/filtersystemd.py @@ -22,7 +22,8 @@ __author__ = "Steven Hiscocks" __copyright__ = "Copyright (c) 2013 Steven Hiscocks" __license__ = "GPL" -import datetime, time +import datetime +import time from distutils.version import LooseVersion from systemd import journal diff --git a/fail2ban/server/jail.py b/fail2ban/server/jail.py index c5b5e707..ef98c4b9 100644 --- a/fail2ban/server/jail.py +++ b/fail2ban/server/jail.py @@ -23,7 +23,8 @@ __author__ = "Cyril Jaquier, Lee Clemens, Yaroslav Halchenko" __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2011-2012 Lee Clemens, 2012 Yaroslav Halchenko" __license__ = "GPL" -import Queue, logging +import logging +import Queue from .actions import Actions from ..helpers import getLogger diff --git a/fail2ban/server/mytime.py b/fail2ban/server/mytime.py index f284379e..16998e24 100644 --- a/fail2ban/server/mytime.py +++ b/fail2ban/server/mytime.py @@ -21,7 +21,8 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import time, datetime +import datetime +import time ## # MyTime class. diff --git a/fail2ban/server/server.py b/fail2ban/server/server.py index c8b0fded..625730f8 100644 --- a/fail2ban/server/server.py +++ b/fail2ban/server/server.py @@ -25,7 +25,12 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" from threading import Lock, RLock -import logging, logging.handlers, sys, os, signal, stat +import logging +import logging.handlers +import os +import signal +import stat +import sys from .jails import Jails from .filter import FileFilter, JournalFilter diff --git a/fail2ban/tests/clientreadertestcase.py b/fail2ban/tests/clientreadertestcase.py index 941116fd..12362efd 100644 --- a/fail2ban/tests/clientreadertestcase.py +++ b/fail2ban/tests/clientreadertestcase.py @@ -21,7 +21,13 @@ __author__ = "Cyril Jaquier, Yaroslav Halchenko" __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2011-2013 Yaroslav Halchenko" __license__ = "GPL" -import os, glob, shutil, tempfile, unittest, re, logging +import glob +import logging +import os +import re +import shutil +import tempfile +import unittest from ..client.configreader import ConfigReaderUnshared from ..client import configparserinc from ..client.jailreader import JailReader diff --git a/fail2ban/tests/samplestestcase.py b/fail2ban/tests/samplestestcase.py index bd2bd2e7..05182acd 100644 --- a/fail2ban/tests/samplestestcase.py +++ b/fail2ban/tests/samplestestcase.py @@ -22,10 +22,15 @@ __copyright__ = "Copyright (c) 2013 Steven Hiscocks" __license__ = "GPL" -import unittest, sys, os, fileinput, re, time, datetime, inspect - +import datetime +import fileinput +import inspect import json - +import os +import re +import sys +import time +import unittest from ..server.filter import Filter from ..client.filterreader import FilterReader from .utils import setUpMyTime, tearDownMyTime, CONFIG_DIR diff --git a/fail2ban/tests/sockettestcase.py b/fail2ban/tests/sockettestcase.py index 8a548998..b710fe37 100644 --- a/fail2ban/tests/sockettestcase.py +++ b/fail2ban/tests/sockettestcase.py @@ -24,7 +24,11 @@ __author__ = "Steven Hiscocks" __copyright__ = "Copyright (c) 2013 Steven Hiscocks" __license__ = "GPL" -import unittest, time, tempfile, os, threading +import os +import tempfile +import threading +import time +import unittest from ..server.asyncserver import AsyncServer, AsyncServerException from ..client.csocket import CSocket diff --git a/setup.py b/setup.py index 5f497a3e..d36ed985 100755 --- a/setup.py +++ b/setup.py @@ -40,7 +40,8 @@ except ImportError: from distutils.command.build_scripts import build_scripts import os from os.path import isfile, join, isdir -import sys, warnings +import sys +import warnings from glob import glob if setuptools and "test" in sys.argv: