Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/
Date: Thu, 30 Apr 2020 22:56:26
Message-Id: 1587666035.ed0de74506f5ce9741fe61c6c1e46701ee7ca3f0.mattst88@gentoo
1 commit: ed0de74506f5ce9741fe61c6c1e46701ee7ca3f0
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Sun Apr 19 18:03:44 2020 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 23 18:20:35 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ed0de745
7
8 catalyst: Add a function to get full path of executable
9
10 Just a simple wrapper around shutil.which().
11
12 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
13
14 catalyst/support.py | 6 ++++++
15 1 file changed, 6 insertions(+)
16
17 diff --git a/catalyst/support.py b/catalyst/support.py
18 index 988a81f5..0925af47 100644
19 --- a/catalyst/support.py
20 +++ b/catalyst/support.py
21 @@ -3,6 +3,7 @@ import glob
22 import sys
23 import os
24 import re
25 +import shutil
26 import time
27 from subprocess import Popen
28
29 @@ -17,6 +18,11 @@ class CatalystError(Exception):
30 if message:
31 log.error('CatalystError: %s', message, exc_info=print_traceback)
32
33 +def command(name):
34 + c = shutil.which(name)
35 + if not c:
36 + raise CatalystError(f'"{name}" not found or is not executable')
37 + return c
38
39 def cmd(mycmd, env=None, debug=False, fail_func=None):
40 """Run the external |mycmd|.