Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CPUnetPLOT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
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:
...
@@ -216,6 +216,9 @@ class CNLParser:
def
get_hostname
(
self
):
def
get_hostname
(
self
):
return
self
.
get_sysinfo
()[
"hostname"
]
return
self
.
get_sysinfo
()[
"hostname"
]
def
get_environment
(
self
):
return
self
.
header
[
"General"
][
"Environment"
]
## MAIN ##
## MAIN ##
...
...
cnlls.py
View file @
d7addebc
...
@@ -77,14 +77,14 @@ def show_summary(left_file, right_file=None):
...
@@ -77,14 +77,14 @@ def show_summary(left_file, right_file=None):
## BRANCH: No match -> fallback to show_brief()
## BRANCH: No match -> fallback to show_brief()
if
(
not
right_file
):
if
(
not
right_file
):
log
=
LogAnalyzer
(
left_file
)
log
=
LogAnalyzer
(
left_file
)
log
.
visualize_brief
()
log
.
visualize_brief
(
args
.
environment
)
## BRANCH: Match -> Display both next to each other.
## BRANCH: Match -> Display both next to each other.
else
:
else
:
log_left
=
LogAnalyzer
(
left_file
)
log_left
=
LogAnalyzer
(
left_file
)
log_right
=
LogAnalyzer
(
right_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
):
def
show
(
left_file
,
right_file
,
long
=
False
,
summary
=
False
):
...
@@ -107,9 +107,8 @@ if __name__ == "__main__":
...
@@ -107,9 +107,8 @@ if __name__ == "__main__":
parser
.
add_argument
(
"files"
,
nargs
=
'*'
)
parser
.
add_argument
(
"files"
,
nargs
=
'*'
)
parser
.
add_argument
(
"-l"
,
"--long"
,
action
=
"store_true"
)
parser
.
add_argument
(
"-l"
,
"--long"
,
action
=
"store_true"
)
parser
.
add_argument
(
"-s"
,
"--summary"
,
action
=
"store_true"
)
parser
.
add_argument
(
"-s"
,
"--summary"
,
action
=
"store_true"
)
parser
.
add_argument
(
"-e"
,
"--environment"
,
action
=
'append'
,
metavar
=
"ENV"
,
## TODO -e, --environment
help
=
"Environment variable that should be displayed. (May be set multiple times.)"
)
# Specify which env-fields should be added to the comment
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
...
summary.py
View file @
d7addebc
...
@@ -5,7 +5,7 @@ import time
...
@@ -5,7 +5,7 @@ import time
import
os
import
os
from
itertools
import
zip_longest
from
itertools
import
zip_longest
from
cnl_library
import
CNLParser
from
cnl_library
import
CNLParser
,
pretty_json
from
split_text
import
split_proprtionally
from
split_text
import
split_proprtionally
## some "constants"/preferences
## some "constants"/preferences
...
@@ -35,7 +35,7 @@ def print_in_two_columns(format_str, left_col, right_col):
...
@@ -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.
Displays a brief summary of two CNL-file next to each other.
...
@@ -43,8 +43,8 @@ def show_match(left_file, right_file):
...
@@ -43,8 +43,8 @@ def show_match(left_file, right_file):
(e.g. sender and receiver).
(e.g. sender and receiver).
"""
"""
left_head
,
left_rates
=
left_file
.
as_column
()
left_head
,
left_rates
=
left_file
.
as_column
(
env
)
right_head
,
right_rates
=
right_file
.
as_column
()
right_head
,
right_rates
=
right_file
.
as_column
(
env
)
## Head
## Head
print_in_two_columns
(
"{:<50} {}"
,
left_head
,
right_head
)
print_in_two_columns
(
"{:<50} {}"
,
left_head
,
right_head
)
...
@@ -173,7 +173,7 @@ class LogAnalyzer:
...
@@ -173,7 +173,7 @@ class LogAnalyzer:
def
as_column
(
self
):
def
as_column
(
self
,
env
=
None
):
## TODO change name?
## TODO change name?
## Head
## Head
...
@@ -187,6 +187,14 @@ class LogAnalyzer:
...
@@ -187,6 +187,14 @@ class LogAnalyzer:
for
comment
in
comments
:
for
comment
in
comments
:
head
.
append
(
comment
.
strip
()[:
48
])
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
## Transmission rates
...
@@ -208,8 +216,8 @@ class LogAnalyzer:
...
@@ -208,8 +216,8 @@ class LogAnalyzer:
def
visualize_brief
(
self
):
def
visualize_brief
(
self
,
env
=
None
):
head
,
rates
=
self
.
as_column
()
head
,
rates
=
self
.
as_column
(
env
)
print_in_two_columns
(
"{:<50} {}"
,
head
,
rates
)
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