check for data directory existence for the sake of logging

This commit is contained in:
Nicholas St. Germain 2018-12-17 22:08:33 -06:00
parent 5cfbbe7a99
commit 7f04419d4c

View file

@ -7,7 +7,7 @@ from urllib3 import disable_warnings
from os import stat, remove, makedirs from os import stat, remove, makedirs
from urllib.request import urlretrieve from urllib.request import urlretrieve
from json.decoder import JSONDecodeError from json.decoder import JSONDecodeError
from os.path import abspath, join, basename from os.path import abspath, join, basename, isdir
from urllib3.exceptions import InsecureRequestWarning from urllib3.exceptions import InsecureRequestWarning
from requests.exceptions import InvalidSchema, SSLError, ConnectionError from requests.exceptions import InvalidSchema, SSLError, ConnectionError
@ -108,8 +108,9 @@ def connection_handler(session, request, verify):
def mkdir_p(path): def mkdir_p(path):
templogger = getLogger('temp') templogger = getLogger('temp')
try: try:
templogger.info('Creating folder %s ', path) if not isdir(path):
makedirs(path, exist_ok=True) templogger.info('Creating folder %s ', path)
makedirs(path, exist_ok=True)
except Exception as e: except Exception as e:
templogger.error('Could not create folder %s : %s ', path, e) templogger.error('Could not create folder %s : %s ', path, e)