From 018316cefdaa001df9cdc3fba6ced8d04de3d8b2 Mon Sep 17 00:00:00 2001 From: Jonas Hahn Date: Sun, 7 Jun 2026 22:31:56 +0200 Subject: [PATCH] Comments --- main.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 75c6cfa..c0912b5 100644 --- a/main.py +++ b/main.py @@ -50,7 +50,6 @@ def classify(line): return None def geo(db, ip): - print(f"Get location for {ip}") row = db.execute("SELECT country, lat, lon FROM ip_geo WHERE ip=?", (ip,)).fetchone() if row: return row @@ -67,6 +66,7 @@ def geo(db, ip): (ip, *data) ) time.sleep(0.1) + print(f"Get location for {ip} to {data[0]}") return data def main(): @@ -92,24 +92,22 @@ def main(): out = subprocess.check_output(cmd, text=True) lines = out.splitlines() - print(f"Parsing {len(lines)} lines") - + added = 0 for line in lines: result = classify(line) if not result: continue ts, ip, port, user, typ = result - - print(f"{typ:18} ip={ip} port={port} user={user}") - db.execute( "INSERT INTO events VALUES (?, ?, ?, ?, ?)", (ts, ip, port, user, typ) ) + added += 1 if ip: geo(db, ip) + db.commit() # save cursor @@ -124,8 +122,8 @@ def main(): break db.close() - print("Done") + + print(f"Parsed {len(lines)} lines and added {added} events") if __name__ == "__main__": main() - print("All done")