Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
uahil
CPUnetPLOT
Commits
d7addebc
Commit
d7addebc
authored
Aug 21, 2014
by
Mario Hock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cnl_ls: --environment
parent
99117969
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
12 deletions
+22
-12
cnl_library.py
cnl_library.py
+3
-0
cnlls.py
cnlls.py
+4
-5
summary.py
summary.py
+15
-7
No files found.
cnl_library.py
View file @
d7addebc
...
...
@@ -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 ##
...
...
cnlls.py
View file @
d7addebc
...
...
@@ -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
()
...
...
summary.py
View file @
d7addebc
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment