Skip to content

Commit ec918f2

Browse files
author
Nathan Lee
committed
Fix to log cleanup
1 parent 9d37558 commit ec918f2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pyrunner/core/pyrunner.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ def cleanup_log_files(self):
246246
return
247247

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

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

256255
for f in to_delete:
257256
print('Deleting File/Directory: {}'.format(f))
258-
shutil.rmtree(f)
257+
if os.path.isdir(f):
258+
shutil.rmtree(f)
259+
else:
260+
os.remove(f)
259261
except Exception:
260262
print("Failure in cleanup_log_files()")
261263
raise

0 commit comments

Comments
 (0)