summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2017-09-26 03:44:13 -0400
committerxudan <xudan16@huawei.com>2017-09-26 04:09:35 -0400
commit3fecd537f9c65a55512abc73e2ee301e1571b281 (patch)
tree198834ce4b6093afa6a04917d27ec3f39bad2f4e
parent6f47c82d4b6f830863ff1330163d869baa6c7eec (diff)
Bugfix: tar results dir cannot be parsed by web portal
The directory tree of results tar file is wrong, so web portal cannot parse it. Reset the tar file. JIRA: DOVETAIL-508 Change-Id: I8475323294e84ca51242b700570926d5c0177390 Signed-off-by: xudan <xudan16@huawei.com>
-rw-r--r--dovetail/report.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/dovetail/report.py b/dovetail/report.py
index fa6a0ba4..995b332d 100644
--- a/dovetail/report.py
+++ b/dovetail/report.py
@@ -14,6 +14,7 @@ import re
import os
import datetime
import tarfile
+import time
from pbr import version
@@ -165,14 +166,19 @@ class Report(object):
@classmethod
def save_logs(cls):
- logs_gz = "logs.tar.gz"
+ file_suffix = time.strftime('%d_%H_%M', time.localtime(time.time()))
+ logs_gz = "logs_{}.tar.gz".format(file_suffix)
result_dir = dt_cfg.dovetail_config['result_dir']
- with tarfile.open(os.path.join(result_dir, logs_gz), "w:gz") as f_out:
+ cwd = os.getcwd()
+ os.chdir(os.path.join(result_dir, '..'))
+ tar_file = os.path.join(result_dir, '..', logs_gz)
+ with tarfile.open(tar_file, "w:gz") as f_out:
files = os.listdir(result_dir)
for f in files:
if f not in ['workspace']:
- f_out.add(os.path.join(result_dir, f))
+ f_out.add(os.path.join('results', f))
+ os.chdir(cwd)
# save to disk as default
@classmethod