aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien <zhang.jun3g@zte.com.cn>2017-06-14 15:33:39 +0800
committerJulien <zhang.jun3g@zte.com.cn>2017-06-14 17:01:13 +0800
commit9111f5ec7a6fbcec824d3c8d4018a7a6e109c466 (patch)
tree7161baa34f2e1f7a556f275e94410682bdc88530
parentb1959f18852ef2b4ce3447130e25c78bc6fb195e (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>
-rw-r--r--.gitignore1
-rw-r--r--anteater.conf6
-rw-r--r--anteater/utils/anteater_logger.py9
3 files changed, 13 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index eeabaeb..a8705c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,4 @@ testapi_venv/
.tox
*.retry
job_output/
+.reports/
diff --git a/anteater.conf b/anteater.conf
index 198ebbc..8dcc897 100644
--- a/anteater.conf
+++ b/anteater.conf
@@ -1,4 +1,4 @@
[config]
-reports_dir = /home/opnfv/reports/
-anteater_log = /home/opnfv/anteater.log
-gate_checks = /home/opnfv/anteater/gatechecks.yaml
+reports_dir = .reports/
+anteater_log = .reports/anteater.log
+gate_checks = ./gatechecks.yaml
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)