From 4d0e7beea7fc4c520263635ba8ed0ba4de883e48 Mon Sep 17 00:00:00 2001 From: Richard Mwewa <74001397+rly0nheart@users.noreply.github.com> Date: Fri, 23 Dec 2022 17:21:53 +0200 Subject: [PATCH] Update octosuite.py --- octosuite/octosuite.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/octosuite/octosuite.py b/octosuite/octosuite.py index cd7ff31..96e1ba6 100644 --- a/octosuite/octosuite.py +++ b/octosuite/octosuite.py @@ -103,11 +103,8 @@ def clear_csv(): xprint(f"{PROMPT} This will clear all {len(os.listdir('output'))} csv files, continue? (yes/no) ", end="") prompt = input().lower() if prompt == "yes": - files = os.listdir('output') - for file in files: - if os.path.isfile(file): - os.remove(file) - xprint(f"{INFO} Cleared {len(files)} .csv files!") + shutil.rmtree('output', ignore_errors=True) + xprint(f"{INFO} .csv files cleared successfully!") else: pass @@ -166,15 +163,11 @@ def delete_log(): # Clear logs def clear_logs(): - xprint( - f"{PROMPT} This will clear all {len(os.listdir('.logs'))} logs and close the current session, continue? (yes/no) ", end="") + xprint(f"{PROMPT} This will clear all {len(os.listdir('.logs'))} logs and close the current session, continue? (yes/no) ", end="") prompt = input().lower() if prompt == "yes": - files = os.listdir('.logs') - for file in files: - if os.path.isfile(file): - os.remove(file) - xprint(f"{INFO} Cleared {len(files)} .log files!") + shutil.rmtree('.logs', ignore_errors=True) + xprint(f"{INFO} .log files cleared successfully!") exit() else: pass