scripts

Personal scripts that don't fit elsewhere

git clone https://code.pdelong.com/scripts.git

 1#!/usr/bin/env python3
 2
 3import sys
 4
 5
 6def main(argv: list[str]) -> int:
 7    if len(argv) != 2:
 8        print("usage: log_file_parsing.py <FILE>")
 9        return 1
10
11    with open(argv[1]) as f:
12        lines = []
13        last = []
14        for line in f:
15            if line.startswith("["):
16                if len(last) != 0:
17                    lines.append("\n".join(last))
18                    last.clear()
19
20            last.append(line.rstrip())
21
22    if len(last) != 0:
23        lines.append("\n".join(last))
24
25    for line in lines:
26        if (
27            "netstack_realm_acquire_then_renew_with_dhcpd_bound_device_ns3_ns2_with_dhcp_out_of_stack_0"
28            in line
29        ):
30            print(line)
31
32    return 0
33
34
35if __name__ == "__main__":
36    exit(main(sys.argv))