add verbose flag and dev-instructions
This commit is contained in:
@@ -78,6 +78,12 @@ def main() -> int:
|
||||
default=True,
|
||||
help="Send 'log on' to the dryer after connect (default: on)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
"--verbose",
|
||||
action="store_true",
|
||||
help="Echo captured CSV rows to stdout; other serial lines to stderr",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
port = args.port
|
||||
@@ -125,22 +131,32 @@ def main() -> int:
|
||||
|
||||
line = raw.decode("utf-8", errors="replace").strip()
|
||||
if not line.startswith("csv_hdr,") and not line.startswith("csv,"):
|
||||
if args.verbose and line:
|
||||
print(line, file=sys.stderr)
|
||||
continue
|
||||
|
||||
if line.startswith("csv_hdr,"):
|
||||
device_header = line[len("csv_hdr,") :]
|
||||
fh.write("wall_time," + device_header + "\n")
|
||||
row = "wall_time," + device_header
|
||||
fh.write(row + "\n")
|
||||
header_written = True
|
||||
fh.flush()
|
||||
if args.verbose:
|
||||
print(row)
|
||||
continue
|
||||
|
||||
if not header_written:
|
||||
fh.write(FALLBACK_HEADER + "\n")
|
||||
header_written = True
|
||||
if args.verbose:
|
||||
print(FALLBACK_HEADER)
|
||||
|
||||
wall_time = datetime.now(timezone.utc).isoformat(timespec="seconds")
|
||||
fh.write(wall_time + "," + line[len("csv,") :] + "\n")
|
||||
row = wall_time + "," + line[len("csv,") :]
|
||||
fh.write(row + "\n")
|
||||
fh.flush()
|
||||
if args.verbose:
|
||||
print(row)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user