From 37fdd01551c923b9eb37e79e0eaa22db683ffe2a Mon Sep 17 00:00:00 2001 From: Michael Scalzetti Date: Wed, 26 Oct 2022 04:13:07 -0400 Subject: [PATCH] added destroy_sniffs, which will destroy the base_dir folder along with all the data in it --- src/sniffer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sniffer.py b/src/sniffer.py index 5012596..7afb153 100644 --- a/src/sniffer.py +++ b/src/sniffer.py @@ -14,7 +14,6 @@ def run_cmd(cmd, out=subprocess.PIPE, timeout=None): return (proc.stdout.read().decode(), proc.stderr.read().decode(), proc.returncode) - class Sniffer: def __init__(self, interface_name): self.ifname = interface_name @@ -37,7 +36,6 @@ class Sniffer: stdout, stderr, code = run_cmd( f"mkdir -p {base_dir}" ) return code == 0 - def sniff(self, timeout): timeout = int(timeout+0.5) dump_file = f"{self.base_dir}/cap-{ int(time.time()) }" @@ -54,4 +52,6 @@ class Sniffer: with open(full_filepath,'r') as file: return csv.DictReader(file) - + def destroy_sniffs(self): + stdout, stderr, code = run_cmd( f"rm -rf {self.base_dir}" ) + return code == 0