From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 346B3138350 for ; Thu, 30 Apr 2020 22:56:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 109C6E0A6F; Thu, 30 Apr 2020 22:56:25 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BFA49E0A6F for ; Thu, 30 Apr 2020 22:56:24 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A93B634F0C1 for ; Thu, 30 Apr 2020 22:56:23 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 52E6D1EB for ; Thu, 30 Apr 2020 22:56:22 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1587666035.ed0de74506f5ce9741fe61c6c1e46701ee7ca3f0.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/support.py X-VCS-Directories: catalyst/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: ed0de74506f5ce9741fe61c6c1e46701ee7ca3f0 X-VCS-Branch: master Date: Thu, 30 Apr 2020 22:56:22 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 03d4e73b-739b-47a6-aedd-c97609cb7656 X-Archives-Hash: 68153bb26f500f2544a4bc8728c7186d commit: ed0de74506f5ce9741fe61c6c1e46701ee7ca3f0 Author: Matt Turner gentoo org> AuthorDate: Sun Apr 19 18:03:44 2020 +0000 Commit: Matt Turner gentoo org> CommitDate: Thu Apr 23 18:20:35 2020 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ed0de745 catalyst: Add a function to get full path of executable Just a simple wrapper around shutil.which(). Signed-off-by: Matt Turner gentoo.org> catalyst/support.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/catalyst/support.py b/catalyst/support.py index 988a81f5..0925af47 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -3,6 +3,7 @@ import glob import sys import os import re +import shutil import time from subprocess import Popen @@ -17,6 +18,11 @@ class CatalystError(Exception): if message: log.error('CatalystError: %s', message, exc_info=print_traceback) +def command(name): + c = shutil.which(name) + if not c: + raise CatalystError(f'"{name}" not found or is not executable') + return c def cmd(mycmd, env=None, debug=False, fail_func=None): """Run the external |mycmd|.