nilmtool list: add new --layout option to show layouts
This commit is contained in:
parent
43b740ecaa
commit
83d022016c
|
@ -19,9 +19,6 @@ def setup(self, sub):
|
|||
group = cmd.add_argument_group("Stream filtering")
|
||||
group.add_argument("path", metavar="PATH", default="*", nargs='?',
|
||||
).completer = self.complete.path
|
||||
group.add_argument("-l", "--layout", default="*",
|
||||
help="Match only this stream layout",
|
||||
).completer = self.complete.layout
|
||||
|
||||
group = cmd.add_argument_group("Interval info")
|
||||
group.add_argument("-E", "--ext", action="store_true",
|
||||
|
@ -45,6 +42,8 @@ def setup(self, sub):
|
|||
group = cmd.add_argument_group("Misc options")
|
||||
group.add_argument("-T", "--timestamp-raw", action="store_true",
|
||||
help="Show raw timestamps when printing times")
|
||||
group.add_argument("-l", "--layout", action="store_true",
|
||||
help="Show layout type next to path name")
|
||||
|
||||
return cmd
|
||||
|
||||
|
@ -68,11 +67,13 @@ def cmd_list(self):
|
|||
|
||||
for stream in streams:
|
||||
(path, layout, int_min, int_max, rows, time) = stream[:6]
|
||||
if not (fnmatch.fnmatch(path, self.args.path) and
|
||||
fnmatch.fnmatch(layout, self.args.layout)):
|
||||
if not fnmatch.fnmatch(path, self.args.path):
|
||||
continue
|
||||
|
||||
printf("%s %s\n", path, layout)
|
||||
if self.args.layout:
|
||||
printf("%s %s\n", path, layout)
|
||||
else:
|
||||
printf("%s\n", path)
|
||||
|
||||
if self.args.ext:
|
||||
if int_min is None or int_max is None:
|
||||
|
|
|
@ -300,26 +300,19 @@ class TestCmdline(object):
|
|||
|
||||
# Verify we got those 3 streams and they're returned in
|
||||
# alphabetical order.
|
||||
self.ok("list")
|
||||
self.ok("list -l")
|
||||
self.match("/newton/prep float32_8\n"
|
||||
"/newton/raw uint16_6\n"
|
||||
"/newton/zzz/rawnotch uint16_9\n")
|
||||
|
||||
# Match just one type or one path. Also check
|
||||
# that --path is optional
|
||||
self.ok("list /newton/raw")
|
||||
self.match("/newton/raw uint16_6\n")
|
||||
|
||||
self.ok("list --layout uint16_6")
|
||||
self.ok("list --layout /newton/raw")
|
||||
self.match("/newton/raw uint16_6\n")
|
||||
|
||||
# Wildcard matches
|
||||
self.ok("list --layout uint16*")
|
||||
self.match("/newton/raw uint16_6\n"
|
||||
"/newton/zzz/rawnotch uint16_9\n")
|
||||
|
||||
self.ok("list *zzz* --layout uint16*")
|
||||
self.match("/newton/zzz/rawnotch uint16_9\n")
|
||||
self.ok("list *zzz*")
|
||||
self.match("/newton/zzz/rawnotch\n")
|
||||
|
||||
# reversed range
|
||||
self.fail("list /newton/prep --start 2020-01-01 --end 2000-01-01")
|
||||
|
@ -657,7 +650,7 @@ class TestCmdline(object):
|
|||
self.match("0\n")
|
||||
|
||||
# Make sure we have the data we expect
|
||||
self.ok("list --detail /newton/prep")
|
||||
self.ok("list -l --detail /newton/prep")
|
||||
self.match("/newton/prep float32_8\n" +
|
||||
" [ Fri, 23 Mar 2012 10:00:00.000000 +0000"
|
||||
" -> Fri, 23 Mar 2012 10:01:59.991668 +0000 ]\n"
|
||||
|
@ -692,7 +685,7 @@ class TestCmdline(object):
|
|||
self.match("24000\n")
|
||||
|
||||
# See the missing chunks in list output
|
||||
self.ok("list --detail /newton/prep")
|
||||
self.ok("list --layout --detail /newton/prep")
|
||||
self.match("/newton/prep float32_8\n" +
|
||||
" [ Fri, 23 Mar 2012 10:00:00.000000 +0000"
|
||||
" -> Fri, 23 Mar 2012 10:00:05.000000 +0000 ]\n"
|
||||
|
@ -706,7 +699,7 @@ class TestCmdline(object):
|
|||
# Remove all data, verify it's missing
|
||||
self.ok("remove /newton/prep --start 2000-01-01 --end 2020-01-01")
|
||||
self.match("") # no count requested this time
|
||||
self.ok("list --detail /newton/prep")
|
||||
self.ok("list -l --detail /newton/prep")
|
||||
self.match("/newton/prep float32_8\n" +
|
||||
" (no intervals)\n")
|
||||
|
||||
|
@ -733,7 +726,7 @@ class TestCmdline(object):
|
|||
self.contain("No stream at path")
|
||||
|
||||
# From previous tests, we have:
|
||||
self.ok("list")
|
||||
self.ok("list -l")
|
||||
self.match("/newton/prep float32_8\n"
|
||||
"/newton/raw uint16_6\n"
|
||||
"/newton/zzz/rawnotch uint16_9\n")
|
||||
|
@ -750,12 +743,12 @@ class TestCmdline(object):
|
|||
|
||||
# Destroy for real
|
||||
self.ok("destroy -R /newton/prep")
|
||||
self.ok("list")
|
||||
self.ok("list -l")
|
||||
self.match("/newton/raw uint16_6\n"
|
||||
"/newton/zzz/rawnotch uint16_9\n")
|
||||
|
||||
self.ok("destroy /newton/zzz/rawnotch")
|
||||
self.ok("list")
|
||||
self.ok("list -l")
|
||||
self.match("/newton/raw uint16_6\n")
|
||||
|
||||
self.ok("destroy /newton/raw")
|
||||
|
@ -785,7 +778,7 @@ class TestCmdline(object):
|
|||
self.ok("destroy /newton/zzz")
|
||||
|
||||
self.ok(u"create /düsseldorf/raw uint16_6")
|
||||
self.ok("list --detail")
|
||||
self.ok("list -l --detail")
|
||||
self.contain(u"/düsseldorf/raw uint16_6")
|
||||
self.contain("(no intervals)")
|
||||
|
||||
|
@ -871,7 +864,7 @@ class TestCmdline(object):
|
|||
du_before = nilmdb.utils.diskusage.du(testdb)
|
||||
|
||||
# Make sure we have the data we expect
|
||||
self.ok("list --detail")
|
||||
self.ok("list -l --detail")
|
||||
self.match("/newton/prep float32_8\n" +
|
||||
" [ Fri, 23 Mar 2012 10:00:00.000000 +0000"
|
||||
" -> Fri, 23 Mar 2012 10:01:59.991668 +0000 ]\n"
|
||||
|
@ -907,7 +900,7 @@ class TestCmdline(object):
|
|||
self.match("3600\n")
|
||||
|
||||
# See the missing chunks in list output
|
||||
self.ok("list --detail")
|
||||
self.ok("list -l --detail")
|
||||
self.match("/newton/prep float32_8\n" +
|
||||
" [ Fri, 23 Mar 2012 10:00:00.000000 +0000"
|
||||
" -> Fri, 23 Mar 2012 10:00:05.000000 +0000 ]\n"
|
||||
|
@ -1031,7 +1024,7 @@ class TestCmdline(object):
|
|||
else:
|
||||
raise AssertionError("data not found at " + seek)
|
||||
# Verify "list" output
|
||||
self.ok("list")
|
||||
self.ok("list -l")
|
||||
self.match("/" + "/".join(components) + " float32_8\n")
|
||||
|
||||
# Lots of renames
|
||||
|
|
Loading…
Reference in New Issue
Block a user