From 98f6d4516e7d8519d89cfcd62ce6de6a5cbe9e67 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Wed, 5 Dec 2018 00:42:43 -0500 Subject: [PATCH] Fix logging and add new make dir function --- varken/helpers.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/varken/helpers.py b/varken/helpers.py index 8806f5b..00ca318 100644 --- a/varken/helpers.py +++ b/varken/helpers.py @@ -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)