From 3a75b4088be0c1c5f49f420d6b38f9621ddd8308 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sun, 26 Jan 2025 22:44:22 +0000 Subject: [PATCH] Make denoise availability error more precise Signed-off-by: Stefan Marr --- rebench/denoise.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/rebench/denoise.py b/rebench/denoise.py index ab66a087..ab510b2f 100755 --- a/rebench/denoise.py +++ b/rebench/denoise.py @@ -81,21 +81,29 @@ def get_cset(self): def set_cset(self, cset_path): self._cset_path = cset_path - def has_denoise(self): + def ensure_denoise(self): if self._denoise_path is None: - self._denoise_path = denoise_py + if os.access(denoise_py, os.X_OK): + self._denoise_path = denoise_py + elif not os.path.isfile(denoise_py): + raise UIError( + f"{denoise_py} not found. " + "Could it be that the user has no access to the file? " + "To use ReBench without denoise, use the --no-denoise option.\n", + None, + ) + else: + raise UIError( + f"{denoise_py} not marked executable. " + f"Please run something similar to `chmod a+x {denoise_py}`. " + "To use ReBench without denoise, use the --no-denoise option.\n", + None, + ) return self._denoise_path is not None and self._denoise_path is not False def get_denoise(self): - if not self.has_denoise(): - raise UIError( - f"{denoise_py} not found. " - "Could it be that the user has no access to the file? " - "To use ReBench without denoise, use the --no-denoise option.\n", - None, - ) - + self.ensure_denoise() return self._denoise_path