From 6c4f7afaea3d4a33c141dc603b0a14de16d673f7 Mon Sep 17 00:00:00 2001 From: AvishaiW Date: Thu, 1 Mar 2018 09:42:07 +0200 Subject: [PATCH] BUG: fixed removing files- check the path, not the file --- catalyst/exchange/utils/exchange_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/catalyst/exchange/utils/exchange_utils.py b/catalyst/exchange/utils/exchange_utils.py index 5c40a26d..658a7002 100644 --- a/catalyst/exchange/utils/exchange_utils.py +++ b/catalyst/exchange/utils/exchange_utils.py @@ -446,12 +446,13 @@ def remove_old_files(algo_name, today, rel_path, environ=None): # run on all files in the folder for f in os.listdir(folder): try: - creation_unix = os.path.getctime(os.path.join(folder, f)) - creation_time = pd.to_datetime(creation_unix, unit='s', ) + file_path = os.path.join(folder, f) + creation_unix = os.path.getctime(file_path) + creation_time = pd.to_datetime(creation_unix, unit='s', utc=True) # if the file is older than 30 days erase it if today - pd.DateOffset(30) > creation_time: - os.unlink(f) + os.unlink(file_path) except OSError: error = 'unable to erase files in {}'.format(folder)