mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 01:24:38 +00:00
Alias: geoip, catch requests errors and log+return. fixes ce2b145185
This commit is contained in:
parent
491c6c1f0a
commit
ea29e4b967
@ -35,6 +35,7 @@ import sys
|
||||
import ujson
|
||||
import requests
|
||||
import zipfile
|
||||
import syslog
|
||||
from configparser import ConfigParser
|
||||
|
||||
|
||||
@ -59,7 +60,11 @@ def download_geolite():
|
||||
if url is not None:
|
||||
# flush data from remote url to temp file and unpack from there
|
||||
with tempfile.NamedTemporaryFile() as tmp_stream:
|
||||
r = requests.get(url)
|
||||
try:
|
||||
r = requests.get(url)
|
||||
except Exception as e:
|
||||
syslog.syslog(syslog.LOG_ERR, 'geoip update failed : %s' % e)
|
||||
return result
|
||||
if r.status_code == 200:
|
||||
tmp_stream.write(r.content)
|
||||
tmp_stream.seek(0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user