From cbe0ec8ea0c99d65e7f9969f62456a71ad3155cc Mon Sep 17 00:00:00 2001 From: Ju Young Lee Date: Wed, 30 May 2018 01:05:40 +0900 Subject: [PATCH] make logs directory if not exists --- main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index af06e97..4a673cf 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import logging import os +import os.path import settings import data_manager from policy_learner import PolicyLearner @@ -11,13 +12,17 @@ # 로그 기록 log_dir = os.path.join(settings.BASE_DIR, 'logs/%s' % stock_code) timestr = settings.get_time_str() + if not os.path.exists('logs'): + os.makedirs('logs') + if not os.path.exists('logs/%s' % stock_code): + os.makedirs('logs/%s' % stock_code) file_handler = logging.FileHandler(filename=os.path.join( log_dir, "%s_%s.log" % (stock_code, timestr)), encoding='utf-8') stream_handler = logging.StreamHandler() file_handler.setLevel(logging.DEBUG) stream_handler.setLevel(logging.INFO) logging.basicConfig(format="%(message)s", - handlers=[file_handler, stream_handler], level=logging.DEBUG) + handlers=[file_handler, stream_handler], level=logging.DEBUG) # 주식 데이터 준비 chart_data = data_manager.load_chart_data(