Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
uyegy
CPUnetPLOT
Commits
4c043a29
Commit
4c043a29
authored
Sep 11, 2014
by
Mario Hock
Browse files
NameSuggestor (for filenames)
parent
80d650c0
Changes
2
Show whitespace changes
Inline
Side-by-side
cnl_library.py
View file @
4c043a29
...
...
@@ -226,6 +226,9 @@ class CNLParser:
def
get_environment
(
self
):
return
self
.
header
[
"General"
][
"Environment"
]
def
get_human_readable_date
(
self
):
return
self
.
header
[
"General"
][
"Date"
][
0
]
## MAIN ##
...
...
simple_plotter.py
View file @
4c043a29
...
...
@@ -133,6 +133,20 @@ def plot_cpu(ax, cnl_file, args):
class
NameSuggestor
:
def
__init__
(
self
):
self
.
date
=
list
()
self
.
hostname
=
list
()
def
add
(
self
,
cnl_file
):
self
.
date
.
append
(
cnl_file
.
get_human_readable_date
()
)
self
.
hostname
.
append
(
cnl_file
.
get_hostname
()
)
def
suggest_filename
(
self
):
print
(
"{}_{}"
.
format
(
self
.
date
[
0
],
"_"
.
join
(
self
.
hostname
)
)
)
## XXX
return
"{}_{}"
.
format
(
self
.
date
[
0
],
"_"
.
join
(
self
.
hostname
)
)
## MAIN ##
if
__name__
==
"__main__"
:
...
...
@@ -186,6 +200,7 @@ if __name__ == "__main__":
num_files
=
len
(
args
.
files
)
name_suggestor
=
NameSuggestor
()
## Create figure (window/file)
fig
=
plt
.
figure
()
...
...
@@ -213,6 +228,7 @@ if __name__ == "__main__":
## Read file
filename
=
args
.
files
[
i
]
cnl_file
=
parse_cnl_file
(
filename
,
nic_fields
)
name_suggestor
.
add
(
cnl_file
)
## update min_x / max_x
min_max
=
get_min_max_x
(
cnl_file
)
...
...
@@ -293,9 +309,11 @@ if __name__ == "__main__":
## Set the default format for the save-botton to PDF.
try
:
fig
.
canvas
.
get_default_filetype
=
lambda
:
"pdf"
fig
.
canvas
.
get_default_filename
=
lambda
:
"cpunetlog.pdf"
## TODO suggest a filename
suggested_name
=
"{}-plot.{}"
.
format
(
name_suggestor
.
suggest_filename
(),
fig
.
canvas
.
get_default_filetype
()
)
name_func
=
lambda
:
suggested_name
fig
.
canvas
.
get_default_filename
=
name_func
except
:
p
ass
p
rint
(
"[WARNING] Filename suggestion failed!"
)
## maximize window
try
:
...
...
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