From c45865e895ac88b21a891f616b7b99d1c98b5a89 Mon Sep 17 00:00:00 2001 From: SET Date: Tue, 18 Aug 2020 22:38:36 -0300 Subject: [PATCH] Modified to avoid removing read-only caches. This is mainly to allow successful tests on CI/CD where we are running as root. In practice is also a good idea to respect the permissions. In real life installers make them r/w. --- kibot/__main__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kibot/__main__.py b/kibot/__main__.py index 751f0a27..dbbb1b97 100644 --- a/kibot/__main__.py +++ b/kibot/__main__.py @@ -226,8 +226,12 @@ def clean_cache(): fnames = glob(os.path.join(cache, f+'.*')) for fname in fnames: if os.path.isfile(fname): - logger.debug('Removing '+fname) - os.remove(fname) + if os.access(fname, os.W_OK): + logger.debug('Removing '+fname) + os.remove(fname) + else: + # Respect the permission, even for root + raise PermissionError() except PermissionError: logger.warning('Wrong installation, avoid creating Python cache files\n' 'If you are using `pip` to install use the `--no-compile` option:\n'