conditionally import dnspython

pull/924/head
Lee Clemens 2015-01-23 16:00:33 -05:00
parent ef3c942808
commit 07a47179a7
1 changed files with 10 additions and 4 deletions

View File

@ -26,9 +26,6 @@ __license__ = "GPL"
from threading import Lock from threading import Lock
import dns.exception
import dns.resolver
from .ticket import BanTicket from .ticket import BanTicket
from .mytime import MyTime from .mytime import MyTime
from ..helpers import getLogger from ..helpers import getLogger
@ -139,8 +136,17 @@ class BanManager:
# @return {"asn": [], "country": [], "rir": []} dict for self.__banList IPs # @return {"asn": [], "country": [], "rir": []} dict for self.__banList IPs
def getBanListExtendedCymruInfo(self): def getBanListExtendedCymruInfo(self):
self.__lock.acquire()
return_dict = {"asn": [], "country": [], "rir": []} return_dict = {"asn": [], "country": [], "rir": []}
try:
import dns.exception
import dns.resolver
except ImportError:
logSys.error("dnspython package is required but could not be imported")
return_dict["asn"].append("error")
return_dict["country"].append("error")
return_dict["rir"].append("error")
return return_dict
self.__lock.acquire()
try: try:
for banData in self.__banList: for banData in self.__banList:
ip = banData.getIP() ip = banData.getIP()