aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/presentation/new/utils.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2018-06-13 15:19:18 +0200
committerTibor Frank <tifrank@cisco.com>2018-06-18 13:12:10 +0000
commit2d001ed910d3835848fccb7bb96a98a5270698fe (patch)
treee659431b6494c7ca14286c94bd36ccd5db9034fa /resources/tools/presentation/new/utils.py
parenta9f251c649a5dea7428a43dc24380077a72dacba (diff)
CSIT-1126: Detection and reporting of failed MRR tests
Change-Id: Iafdd12a573b58ab3ba9c69699cd97c5a4e598601 Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/presentation/new/utils.py')
-rw-r--r--resources/tools/presentation/new/utils.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/resources/tools/presentation/new/utils.py b/resources/tools/presentation/new/utils.py
index a4e24663b5..a2aa0dc071 100644
--- a/resources/tools/presentation/new/utils.py
+++ b/resources/tools/presentation/new/utils.py
@@ -17,8 +17,9 @@
import multiprocessing
import subprocess
import numpy as np
-import pandas as pd
import logging
+import csv
+import prettytable
from os import walk, makedirs, environ
from os.path import join, isdir
@@ -253,6 +254,29 @@ def classify_anomalies(data):
return classification, avgs
+def convert_csv_to_pretty_txt(csv_file, txt_file):
+ """Convert the given csv table to pretty text table.
+
+ :param csv_file: The path to the input csv file.
+ :param txt_file: The path to the output pretty text file.
+ :type csv_file: str
+ :type txt_file: str
+ """
+
+ txt_table = None
+ with open(csv_file, 'rb') as csv_file:
+ csv_content = csv.reader(csv_file, delimiter=',', quotechar='"')
+ for row in csv_content:
+ if txt_table is None:
+ txt_table = prettytable.PrettyTable(row)
+ else:
+ txt_table.add_row(row)
+ txt_table.align["Test case"] = "l"
+ if txt_table:
+ with open(txt_file, "w") as txt_file:
+ txt_file.write(str(txt_table))
+
+
class Worker(multiprocessing.Process):
"""Worker class used to process tasks in separate parallel processes.
"""