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
73ace0a6
Commit
73ace0a6
authored
Sep 05, 2014
by
Mario Hock
Browse files
cnl_ls: Ignore non-cnl-files (e.g., README.txt)
parent
d88a4c23
Changes
2
Hide whitespace changes
Inline
Side-by-side
cnl_library.py
View file @
73ace0a6
...
...
@@ -92,14 +92,18 @@ def read_header(f):
return
header
class
CNLParser
:
class
WrongFileFormat_Exception
(
Exception
):
pass
def
__init__
(
self
,
filename
):
self
.
filename
=
filename
with
open
(
self
.
filename
)
as
in_file
:
## Check file format version.
assert
(
in_file
.
readline
()
==
"%% CPUnetLOGv1
\n
"
)
if
(
not
in_file
.
readline
()
==
"%% CPUnetLOGv1
\n
"
):
raise
self
.
WrongFileFormat_Exception
()
## Read JSON header.
self
.
header
=
read_header
(
in_file
)
...
...
cnlls.py
View file @
73ace0a6
...
...
@@ -125,7 +125,12 @@ if __name__ == "__main__":
## Parse files and store them in a dict (of lists) according to their hostname.
for
filename
in
filenames
:
cnl_file
=
CNLParser
(
filename
)
try
:
cnl_file
=
CNLParser
(
filename
)
except
CNLParser
.
WrongFileFormat_Exception
:
print
(
"Skipping: {}"
.
format
(
filename
)
)
continue
hostname
=
cnl_file
.
get_hostname
()
cnl_files
[
hostname
].
append
(
cnl_file
)
...
...
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