Add commandline support for listing extents
This commit is contained in:
parent
00237e30b2
commit
1ccc2bce7e
|
@ -24,17 +24,24 @@ def setup(self, sub):
|
|||
group.add_argument("-l", "--layout", default="*",
|
||||
help="Match only this stream layout")
|
||||
|
||||
group = cmd.add_argument_group("Interval extent")
|
||||
group.add_argument("-E", "--extent", action="store_true",
|
||||
help="Show min/max timestamps in this stream")
|
||||
|
||||
group = cmd.add_argument_group("Interval details")
|
||||
group.add_argument("-d", "--detail", action="store_true",
|
||||
help="Show available data time intervals")
|
||||
group.add_argument("-T", "--timestamp-raw", action="store_true",
|
||||
help="Show raw timestamps in time intervals")
|
||||
group.add_argument("-s", "--start",
|
||||
metavar="TIME", type=self.arg_time,
|
||||
help="Starting timestamp (free-form, inclusive)")
|
||||
group.add_argument("-e", "--end",
|
||||
metavar="TIME", type=self.arg_time,
|
||||
help="Ending timestamp (free-form, noninclusive)")
|
||||
|
||||
group = cmd.add_argument_group("Misc options")
|
||||
group.add_argument("-T", "--timestamp-raw", action="store_true",
|
||||
help="Show raw timestamps in time intervals or extents")
|
||||
|
||||
return cmd
|
||||
|
||||
def cmd_list_verify(self):
|
||||
|
@ -52,28 +59,38 @@ def cmd_list_verify(self):
|
|||
if self.args.start >= self.args.end:
|
||||
self.parser.error("start must precede end")
|
||||
|
||||
if self.args.start is not None or self.args.end is not None:
|
||||
if not self.args.detail:
|
||||
self.parser.error("--start and --end only make sense with --detail")
|
||||
|
||||
def cmd_list(self):
|
||||
"""List available streams"""
|
||||
streams = self.client.stream_list()
|
||||
streams = self.client.stream_list(extent = True)
|
||||
|
||||
if self.args.timestamp_raw:
|
||||
time_string = repr
|
||||
else:
|
||||
time_string = nilmdb.utils.time.format_time
|
||||
|
||||
for (path, layout) in streams:
|
||||
for (path, layout, extent_min, extent_max) in streams:
|
||||
if not (fnmatch.fnmatch(path, self.args.path) and
|
||||
fnmatch.fnmatch(layout, self.args.layout)):
|
||||
continue
|
||||
|
||||
printf("%s %s\n", path, layout)
|
||||
if not self.args.detail:
|
||||
continue
|
||||
|
||||
printed = False
|
||||
for (start, end) in self.client.stream_intervals(path, self.args.start,
|
||||
self.args.end):
|
||||
printf(" [ %s -> %s ]\n", time_string(start), time_string(end))
|
||||
printed = True
|
||||
if not printed:
|
||||
printf(" (no intervals)\n")
|
||||
if self.args.extent:
|
||||
if extent_min is None or extent_max is None:
|
||||
printf(" extent: (no data)\n")
|
||||
else:
|
||||
printf(" extent: %s -> %s\n",
|
||||
time_string(extent_min), time_string(extent_max))
|
||||
|
||||
if self.args.detail:
|
||||
printed = False
|
||||
for (start, end) in self.client.stream_intervals(
|
||||
path, self.args.start, self.args.end):
|
||||
printf(" [ %s -> %s ]\n", time_string(start), time_string(end))
|
||||
printed = True
|
||||
if not printed:
|
||||
printf(" (no intervals)\n")
|
||||
|
|
Loading…
Reference in New Issue
Block a user