From 2f09d2398bb351a8d92f179de3a4d9dca62a4c01 Mon Sep 17 00:00:00 2001 From: Michael Scalzetti Date: Wed, 26 Oct 2022 03:53:00 -0400 Subject: [PATCH] rewriting run_cmd a bit more to handle timout errors --- src/sniffer.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sniffer.py b/src/sniffer.py index b67df16..2ec9865 100644 --- a/src/sniffer.py +++ b/src/sniffer.py @@ -5,7 +5,11 @@ def run_cmd(cmd, out=subprocess.PIPE, timeout=None): # Just runs a command, supports changing the pipe n stuff proc = subprocess.Popen(cmd, stdout = out, stderr = subprocess.PIPE, shell=True) - proc.wait(timeout=timeout) + + try: + proc.wait(timeout=timeout) + except subprocess.TimeoutExpired: + return ("","",-1) return (proc.stdout.read().decode(), proc.stderr.read().decode(), proc.returncode) @@ -44,10 +48,6 @@ class Sniffer: if code != 0: return code - #time.sleep(timeout+.1) # Give a bit of time for airodump to write - - #stdout, code = run_cmd(f"killall -i airodump-ng") - full_filepath = f"{dump_file}-01.csv" return self.parse_sniff(full_filepath)