From 8827cc96ae86def1fddaa51ea2249c5a9f1f0b57 Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Thu, 6 Jan 2022 20:00:45 +0100 Subject: [PATCH] whisper-update takes values from stdin (#318) (#319) - also mention this in --help text (cherry picked from commit 3ce395e2561daae852bbe292ee973bd559d21040) Co-authored-by: rowlap --- bin/whisper-update.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/whisper-update.py b/bin/whisper-update.py index 80416f17..a62a6f43 100755 --- a/bin/whisper-update.py +++ b/bin/whisper-update.py @@ -16,16 +16,22 @@ now = int(time.time()) option_parser = optparse.OptionParser( - usage='''%prog [options] path timestamp:value [timestamp:value]*''') + usage='''%prog [options] path [timestamp:value]* + + If no values are passed as arguments, they are read one-per-line from stdin.''') (options, args) = option_parser.parse_args() -if len(args) < 2: +if not args: option_parser.print_help() sys.exit(1) path = args[0] -datapoint_strings = args[1:] +if len(args) >= 2: + datapoint_strings = args[1:] +else: + # no argv values, so read from stdin + datapoint_strings = sys.stdin datapoint_strings = [point.replace('N:', '%d:' % now) for point in datapoint_strings] datapoints = [tuple(point.split(':')) for point in datapoint_strings]