Commit d7addebc authored by Mario Hock's avatar Mario Hock

cnl_ls: --environment

parent 99117969
......@@ -216,6 +216,9 @@ class CNLParser:
def get_hostname(self):
return self.get_sysinfo()["hostname"]
def get_environment(self):
return self.header["General"]["Environment"]
## MAIN ##
......
......@@ -77,14 +77,14 @@ def show_summary(left_file, right_file=None):
## BRANCH: No match -> fallback to show_brief()
if ( not right_file ):
log = LogAnalyzer(left_file)
log.visualize_brief()
log.visualize_brief(args.environment)
## BRANCH: Match -> Display both next to each other.
else:
log_left = LogAnalyzer(left_file)
log_right = LogAnalyzer(right_file)
show_match(log_left, log_right)
show_match(log_left, log_right, args.environment)
def show(left_file, right_file, long=False, summary=False):
......@@ -107,9 +107,8 @@ if __name__ == "__main__":
parser.add_argument("files", nargs='*')
parser.add_argument("-l", "--long", action="store_true")
parser.add_argument("-s", "--summary", action="store_true")
## TODO -e, --environment
# Specify which env-fields should be added to the comment
parser.add_argument("-e", "--environment", action='append', metavar="ENV",
help="Environment variable that should be displayed. (May be set multiple times.)")
args = parser.parse_args()
......
......@@ -5,7 +5,7 @@ import time
import os
from itertools import zip_longest
from cnl_library import CNLParser
from cnl_library import CNLParser, pretty_json
from split_text import split_proprtionally
## some "constants"/preferences
......@@ -35,7 +35,7 @@ def print_in_two_columns(format_str, left_col, right_col):
def show_match(left_file, right_file):
def show_match(left_file, right_file, env=None):
"""
Displays a brief summary of two CNL-file next to each other.
......@@ -43,8 +43,8 @@ def show_match(left_file, right_file):
(e.g. sender and receiver).
"""
left_head, left_rates = left_file.as_column()
right_head, right_rates = right_file.as_column()
left_head, left_rates = left_file.as_column(env)
right_head, right_rates = right_file.as_column(env)
## Head
print_in_two_columns("{:<50} {}", left_head, right_head)
......@@ -173,7 +173,7 @@ class LogAnalyzer:
def as_column(self):
def as_column(self, env=None):
## TODO change name?
## Head
......@@ -187,6 +187,14 @@ class LogAnalyzer:
for comment in comments:
head.append(comment.strip()[:48])
if ( env ):
env_head = self.cnl_file.get_environment()
for e in env:
head.append( '{}: {}'.format(e, pretty_json(env_head[e])) )
head.append("Duration: {}s".format(round(self.experiment_duration)) )
## Transmission rates
......@@ -208,8 +216,8 @@ class LogAnalyzer:
def visualize_brief(self):
head, rates = self.as_column()
def visualize_brief(self, env=None):
head, rates = self.as_column(env)
print_in_two_columns("{:<50} {}", head, rates )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment