better error handling when cleaning old runs

This commit is contained in:
Fredrik Eriksson 2020-12-17 13:04:44 +01:00
parent 3846e8f303
commit 572f43010e
Signed by: feffe
GPG Key ID: F4329687B0FA7F8D
2 changed files with 9 additions and 3 deletions

View File

@ -159,7 +159,10 @@ def print_runs(runs, clean=True):
print("\n\n") print("\n\n")
if clean: if clean:
for run in runs: for run in runs:
shutil.rmtree(run) try:
shutil.rmtree(run)
except FileNotFoundError:
pass
def main(): def main():
time_format = '%Y-%m-%d_%H%M' time_format = '%Y-%m-%d_%H%M'
@ -215,7 +218,10 @@ def main():
if previous_runs: if previous_runs:
print("Success after {} failed runs\n".format(len(previous_runs))) print("Success after {} failed runs\n".format(len(previous_runs)))
print_runs(previous_runs.keys()) print_runs(previous_runs.keys())
shutil.rmtree(libdir) try:
shutil.rmtree(libdir)
except FileNotFoundError:
pass
return 0 return 0

View File

@ -5,7 +5,7 @@ with open('README.md', 'r') as fh:
setuptools.setup( setuptools.setup(
name='cronwrapper', name='cronwrapper',
version='0.1.2', version='0.1.3',
author='Fredrik Eriksson', author='Fredrik Eriksson',
author_email='feffe@fulh.ax', author_email='feffe@fulh.ax',
description='A small wrapper to handle cronjob failures', description='A small wrapper to handle cronjob failures',