public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Subject: [gentoo-catalyst] [PATCH] main: use find_binary from snakeoil
Date: Thu,  8 Oct 2015 16:21:27 -0400	[thread overview]
Message-ID: <1444335687-29173-1-git-send-email-vapier@gentoo.org> (raw)

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



             reply	other threads:[~2015-10-08 20:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-08 20:21 Mike Frysinger [this message]
2015-10-08 20:32 ` [gentoo-catalyst] [PATCH] main: use find_binary from snakeoil Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444335687-29173-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gentoo-catalyst@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox