summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhongbo tian <hongbo.tianhongbo@huawei.com>2016-11-09 07:15:18 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-11-09 07:15:18 +0000
commitd149ee668234a24429cafc48c6c26a89ec950504 (patch)
treeca68faf47d0a2e742011067d76ed4e42f85d8273
parent976d8e0640e478c79002f402bbe9996955c02629 (diff)
parent65a0b1dc65bc0df69c68b7fa176f5035e5b5511f (diff)
Merge "dovetail tool: cleanup result directory before running"
-rw-r--r--dovetail/utils/dovetail_logger.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/dovetail/utils/dovetail_logger.py b/dovetail/utils/dovetail_logger.py
index bd13508d..9cd8719b 100644
--- a/dovetail/utils/dovetail_logger.py
+++ b/dovetail/utils/dovetail_logger.py
@@ -24,6 +24,18 @@
import logging
import os
+from conf.dovetail_config import dovetail_config
+import dovetail_utils as dt_utils
+
+
+def clean_results_dir():
+ result_path = dovetail_config['result_dir']
+ if os.path.exists(result_path):
+ cmd = 'sudo rm -rf %s' % (result_path)
+ dt_utils.exec_cmd(cmd)
+
+clean_results_dir()
+
class Logger:
def __init__(self, logger_name):
@@ -44,9 +56,10 @@ class Logger:
ch.setLevel(logging.INFO)
self.logger.addHandler(ch)
- if not os.path.exists('/home/opnfv/dovetail/results/'):
- os.makedirs('/home/opnfv/dovetail/results/')
- hdlr = logging.FileHandler('/home/opnfv/dovetail/results/dovetail.log')
+ result_path = dovetail_config['result_dir']
+ if not os.path.exists(result_path):
+ os.makedirs(result_path)
+ hdlr = logging.FileHandler(os.path.join(result_path, 'dovetail.log'))
hdlr.setFormatter(formatter)
hdlr.setLevel(logging.DEBUG)
self.logger.addHandler(hdlr)