Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
e5bf87c7ab
|
|||
a69cde3160
|
|||
572f43010e
|
|||
3846e8f303
|
|||
07ccb09910
|
@ -79,7 +79,7 @@ def parse_args():
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if not args.name:
|
if not args.name:
|
||||||
args.name = [os.path.basename(args.command[0])]
|
args.name = os.path.basename(args.command[0])
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@ -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'
|
||||||
@ -204,10 +207,16 @@ def main():
|
|||||||
|
|
||||||
previous_runs = {}
|
previous_runs = {}
|
||||||
for root, dirs, files in os.walk(os.path.join(args.cachedir[0], args.name)):
|
for root, dirs, files in os.walk(os.path.join(args.cachedir[0], args.name)):
|
||||||
previous_runs = {
|
for d in dirs:
|
||||||
os.path.join(root, d): datetime.datetime.strptime(d, time_format)
|
if datetime.datetime.strptime(d, time_format) < datetime.datetime.strptime(nowstr, time_format):
|
||||||
for d in dirs
|
with open(os.path.join(root, d, 'result'), 'r') as f:
|
||||||
if datetime.datetime.strptime(d, time_format) < datetime.datetime.strptime(nowstr, time_format)}
|
try:
|
||||||
|
retcode = f.read().splitlines()[-1]
|
||||||
|
except IndexError:
|
||||||
|
# Previous run is probably not completed yet, ignore
|
||||||
|
# this entry
|
||||||
|
continue
|
||||||
|
previous_runs[os.path.join(root, d)] = datetime.datetime.strptime(d, time_format)
|
||||||
break
|
break
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
@ -215,7 +224,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
|
||||||
|
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open('README.md', 'r') as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='cronwrapper',
|
name='cronwrapper',
|
||||||
version='0.1.1',
|
version='0.1.4',
|
||||||
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',
|
||||||
|
Reference in New Issue
Block a user