public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] [PATCH] main: use find_binary from snakeoil
@ 2015-10-08 20:21 Mike Frysinger
  2015-10-08 20:32 ` Brian Dolbec
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2015-10-08 20:21 UTC (permalink / raw
  To: gentoo-catalyst

No point in duplicating our own version when snakeoil provides it.
---
 catalyst/main.py    | 12 +++++++++---
 catalyst/support.py | 13 -------------
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/catalyst/main.py b/catalyst/main.py
index 65e34ef..03c13c0 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -10,6 +10,8 @@ import argparse
 import os
 import sys
 
+from snakeoil import process
+
 __selfpath__ = os.path.abspath(os.path.dirname(__file__))
 
 from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
@@ -20,7 +22,7 @@ import catalyst.config
 import catalyst.util
 from catalyst.defaults import confdefaults, option_messages
 from catalyst.hash_utils import HashMap, HASH_DEFINITIONS
-from catalyst.support import CatalystError, find_binary
+from catalyst.support import CatalystError
 from catalyst.version import get_version
 
 
@@ -283,7 +285,9 @@ def main():
 
 		# Then check for any programs that the hash func requires.
 		for digest in digests:
-			if find_binary(hash_map.hash_map[digest].cmd) == None:
+			try:
+				process.find_binary(hash_map.hash_map[digest].cmd)
+			except process.CommandNotFound:
 				# In auto mode, just ignore missing support.
 				if skip_missing:
 					digests.remove(digest)
@@ -309,7 +313,9 @@ def main():
 			print
 			print "Catalyst aborting...."
 			sys.exit(2)
-		if find_binary(hash_map.hash_map[conf_values["hash_function"]].cmd) == None:
+		try:
+			process.find_binary(hash_map.hash_map[conf_values["hash_function"]].cmd)
+		except process.CommandNotFound:
 			print
 			print "hash_function="+conf_values["hash_function"]
 			print "\tThe "+hash_map.hash_map[conf_values["hash_function"]].cmd + \
diff --git a/catalyst/support.py b/catalyst/support.py
index a26e49c..1207d36 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -64,19 +64,6 @@ def warn(msg):
 	print "!!! catalyst: "+msg
 
 
-def find_binary(myc):
-	"""look through the environmental path for an executable file named whatever myc is"""
-	# this sucks. badly.
-	p=os.getenv("PATH")
-	if p == None:
-		return None
-	for x in p.split(":"):
-		#if it exists, and is executable
-		if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
-			return "%s/%s" % (x,myc)
-	return None
-
-
 def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
 	if env is None:
 		env = {}
-- 
2.5.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-catalyst] [PATCH] main: use find_binary from snakeoil
  2015-10-08 20:21 [gentoo-catalyst] [PATCH] main: use find_binary from snakeoil Mike Frysinger
@ 2015-10-08 20:32 ` Brian Dolbec
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2015-10-08 20:32 UTC (permalink / raw
  To: gentoo-catalyst

On Thu,  8 Oct 2015 16:21:27 -0400
Mike Frysinger <vapier@gentoo.org> wrote:

> No point in duplicating our own version when snakeoil provides it.
> ---
>  catalyst/main.py    | 12 +++++++++---
>  catalyst/support.py | 13 -------------
>  2 files changed, 9 insertions(+), 16 deletions(-)
> 
>

:)  looks good

-- 
Brian Dolbec <dolsen>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-08 20:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-08 20:21 [gentoo-catalyst] [PATCH] main: use find_binary from snakeoil Mike Frysinger
2015-10-08 20:32 ` Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox