From 2cc9ac63e68d60bae248e4c6775624ffc37f6a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Thu, 18 Apr 2024 23:03:24 +0200 Subject: [PATCH] fixed number of results to keep --- src/is_workflow.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/is_workflow.py b/src/is_workflow.py index a2b2059..33eb99e 100755 --- a/src/is_workflow.py +++ b/src/is_workflow.py @@ -238,10 +238,10 @@ class BeltsGraphCreator(GraphCreator): files = [os.path.join(folder, f) for f in os.listdir(folder) if f.endswith('.png')] files.sort(key=os.path.getmtime, reverse=True) - if len(files) <= keep_results + 1: + if len(files) <= keep_results: return else: - for old_file in files[keep_results + 1 :]: + for old_file in files[keep_results:]: file_date = '_'.join(os.path.splitext(os.path.basename(old_file))[0].split('_')[1:3]) for suffix in ['A', 'B']: csv_file = os.path.join(folder, f'belt_{file_date}_{suffix}.csv') @@ -275,10 +275,10 @@ class ShaperGraphCreator(GraphCreator): files = [os.path.join(folder, f) for f in os.listdir(folder) if f.endswith('.png')] files.sort(key=os.path.getmtime, reverse=True) - if len(files) <= 2 * keep_results + 1: + if len(files) <= 2 * keep_results: return else: # delete the older files - for old_file in files[2 * keep_results + 1 :]: + for old_file in files[2 * keep_results :]: csv_file = os.path.join(folder, os.path.splitext(os.path.basename(old_file))[0] + '.csv') if os.path.exists(csv_file): os.remove(csv_file) @@ -316,10 +316,10 @@ class VibrationsGraphCreator(GraphCreator): files = [os.path.join(folder, f) for f in os.listdir(folder) if f.endswith('.png')] files.sort(key=os.path.getmtime, reverse=True) - if len(files) <= keep_results + 1: + if len(files) <= keep_results: return else: # delete the older files - for old_file in files[keep_results + 1 :]: + for old_file in files[keep_results:]: os.remove(old_file) tar_file = os.path.join(folder, os.path.splitext(os.path.basename(old_file))[0] + '.tar.gz') if os.path.exists(tar_file):