Add URLError error catching. Fixes #164
This commit is contained in:
parent
3adc6b684e
commit
d5f7cae46e
1 changed files with 5 additions and 1 deletions
|
@ -3,7 +3,7 @@ from datetime import date, timedelta
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError, URLError
|
||||||
from geoip2.database import Reader
|
from geoip2.database import Reader
|
||||||
from tarfile import open as taropen
|
from tarfile import open as taropen
|
||||||
from urllib3 import disable_warnings
|
from urllib3 import disable_warnings
|
||||||
|
@ -88,6 +88,10 @@ class GeoIPHandler(object):
|
||||||
try:
|
try:
|
||||||
urlretrieve(maxmind_url, tar_dbfile)
|
urlretrieve(maxmind_url, tar_dbfile)
|
||||||
downloaded = True
|
downloaded = True
|
||||||
|
except URLError as e:
|
||||||
|
self.logger.error("Problem downloading new MaxMind DB: %s", e)
|
||||||
|
result_status = 1
|
||||||
|
return result_status
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
if e.code == 401:
|
if e.code == 401:
|
||||||
self.logger.error("Your MaxMind license key is incorect! Check your config: %s", e)
|
self.logger.error("Your MaxMind license key is incorect! Check your config: %s", e)
|
||||||
|
|
Loading…
Reference in a new issue