Fix logging and add new make dir function

This commit is contained in:
samwiseg0 2018-12-05 00:42:43 -05:00
parent 8289a93830
commit 98f6d4516e

View file

@ -4,6 +4,7 @@ import tarfile
import hashlib
import geoip2.database
import logging
from functools import update_wrapper
from json.decoder import JSONDecodeError
from os.path import abspath, join
@ -67,13 +68,21 @@ def connection_handler(session, request, verify):
try:
return_json = get.json()
except JSONDecodeError:
logger.info('No JSON response... BORKED! Let us know in discord')
logger.error('No JSON response... BORKED! Let us know in discord')
except InvalidSchema:
logger.info('You added http(s):// in the config file. Don\'t do that.')
logger.error('You added http(s):// in the config file. Don\'t do that.')
except SSLError as e:
logger.info('Either your host is unreachable or you have an ssl issue.')
logger.info('The issue was: {}'.format(e))
logger.error('Either your host is unreachable or you have an SSL issue. : %s', e)
return return_json
def mkdir_p(path):
"""http://stackoverflow.com/a/600612/190597 (tzot)"""
try:
logger.info('Creating folder %s ', path)
os.makedirs(path, exist_ok=True)
except Exception as e:
logger.error('Could not create folder %s : %s ', path, e)