Skip to content

Commit

Permalink
Fix to log cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Lee committed Dec 12, 2020
1 parent 9d37558 commit ec918f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pyrunner/core/pyrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ def cleanup_log_files(self):
return

try:

files = glob.glob('{}/*'.format(self.config['root_log_dir']))
to_delete = [ f for f in files if os.stat(f).st_mtime < (time.time() - (self.config['log_retention'] * 86400.0)) ]

Expand All @@ -255,7 +254,10 @@ def cleanup_log_files(self):

for f in to_delete:
print('Deleting File/Directory: {}'.format(f))
shutil.rmtree(f)
if os.path.isdir(f):
shutil.rmtree(f)
else:
os.remove(f)
except Exception:
print("Failure in cleanup_log_files()")
raise
Expand Down

0 comments on commit ec918f2

Please sign in to comment.