From a318a637a5347e0986d878404d35e4b649f9ca3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=B6hn?= Date: Tue, 19 Jun 2018 14:47:03 +0200 Subject: [PATCH] vmtools: use pythonic way to check for installed binaries --- fdroidserver/vmtools.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/fdroidserver/vmtools.py b/fdroidserver/vmtools.py index 5150e8c3..f085afaf 100644 --- a/fdroidserver/vmtools.py +++ b/fdroidserver/vmtools.py @@ -120,18 +120,9 @@ def get_build_vm(srvdir, provider=None): logging.warn('build vm provider not supported: \'%s\'', provider) # try guessing provider from installed software - try: - kvm_installed = 0 == _check_call(['which', 'kvm']) - except subprocess.CalledProcessError: - kvm_installed = False - try: - kvm_installed |= 0 == _check_call(['which', 'qemu']) - except subprocess.CalledProcessError: - pass - try: - vbox_installed = 0 == _check_call(['which', 'VBoxHeadless']) - except subprocess.CalledProcessError: - vbox_installed = False + kvm_installed = shutil.which('kvm') is not None + kvm_installed |= shutil.which('qemu') is not None + vbox_installed = shutil.which('VBoxHeadless') is not None if kvm_installed and vbox_installed: logging.debug('both kvm and vbox are installed.') elif kvm_installed: