From b8ec23b69dadbda772f671b0c2f4c4ef662971ea Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 11 Apr 2019 14:43:43 -0700 Subject: envconfig: simplify exception handling. Currently this takes a return value, and in the error case sets it, then has a separate if to hanle that. Instead just set the return value in the error handler. --- mesonbuild/envconfig.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index e211945f4..d3b1989d6 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -327,17 +327,13 @@ class BinaryTable(HasEnvVarFallback): 'pkgconfig': 'PKG_CONFIG', } - @classmethod - def detect_ccache(cls): + @staticmethod + def detect_ccache(): try: - has_ccache = subprocess.call(['ccache', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - except OSError: - has_ccache = 1 - if has_ccache == 0: - cmdlist = ['ccache'] - else: - cmdlist = [] - return cmdlist + subprocess.check_call(['ccache', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except (OSError, subprocess.CalledProcessError): + return [] + return ['ccache'] @classmethod def _warn_about_lang_pointing_to_cross(cls, compiler_exe, evar): -- cgit v1.2.3