From 572f43010e4175234251ea0ae776b6776ee3bdc1 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Thu, 17 Dec 2020 13:04:44 +0100 Subject: [PATCH] better error handling when cleaning old runs --- cronwrapper/__init__.py | 10 ++++++++-- setup.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cronwrapper/__init__.py b/cronwrapper/__init__.py index 60d21ec..b586553 100755 --- a/cronwrapper/__init__.py +++ b/cronwrapper/__init__.py @@ -159,7 +159,10 @@ def print_runs(runs, clean=True): print("\n\n") if clean: for run in runs: - shutil.rmtree(run) + try: + shutil.rmtree(run) + except FileNotFoundError: + pass def main(): time_format = '%Y-%m-%d_%H%M' @@ -215,7 +218,10 @@ def main(): if previous_runs: print("Success after {} failed runs\n".format(len(previous_runs))) print_runs(previous_runs.keys()) - shutil.rmtree(libdir) + try: + shutil.rmtree(libdir) + except FileNotFoundError: + pass return 0 diff --git a/setup.py b/setup.py index e3553bf..d7ba09b 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open('README.md', 'r') as fh: setuptools.setup( name='cronwrapper', - version='0.1.2', + version='0.1.3', author='Fredrik Eriksson', author_email='feffe@fulh.ax', description='A small wrapper to handle cronjob failures',