diff options
author | Julien <zhang.jun3g@zte.com.cn> | 2017-06-14 15:33:39 +0800 |
---|---|---|
committer | Julien <zhang.jun3g@zte.com.cn> | 2017-06-14 17:01:13 +0800 |
commit | 9111f5ec7a6fbcec824d3c8d4018a7a6e109c466 (patch) | |
tree | 7161baa34f2e1f7a556f275e94410682bdc88530 /anteater | |
parent | b1959f18852ef2b4ce3447130e25c78bc6fb195e (diff) |
Fix log directory issues
1. /home/opnfv can not be created in osx
2. when the log directory is not existed, anteater_logger.py will fail
3. add new added directory .reports into .gitignore
Change-Id: If3833bfbaf160d35afab1c71d3fab060a1164da6
Signed-off-by: Julien <zhang.jun3g@zte.com.cn>
Diffstat (limited to 'anteater')
-rw-r--r-- | anteater/utils/anteater_logger.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/anteater/utils/anteater_logger.py b/anteater/utils/anteater_logger.py index ae9f356..1fe705f 100644 --- a/anteater/utils/anteater_logger.py +++ b/anteater/utils/anteater_logger.py @@ -11,6 +11,7 @@ import ConfigParser import logging +import os config = ConfigParser.RawConfigParser() config.read('anteater.conf') @@ -30,6 +31,14 @@ class Logger: ch.setLevel(logging.DEBUG) self.logger.addHandler(ch) + # create the directory if not existed + path = os.path.dirname(anteater_log) + if ( False == os.path.exists(path)): + try: + os.makedirs(path) + except OSError as e: + raise e + handler = logging.FileHandler(anteater_log) handler.setFormatter(formatter) handler.setLevel(logging.DEBUG) |