From b40cd6885162e967560c7a3d32998eb36bf0801d Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sun, 11 Jan 2009 12:36:25 -0600 Subject: [PATCH] Move find_binary() from catalyst.support to catalyst.util --- ChangeLog | 4 ++++ catalyst | 4 ++-- modules/catalyst/support.py | 16 ++-------------- modules/catalyst/util.py | 13 +++++++++++++ 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4e20e62..e8412a5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 11 Jan 2009; Andrew Gaffney catalyst, + modules/catalyst/support.py, modules/catalyst/util.py: + Move find_binary() from catalyst.support to catalyst.util + 11 Jan 2009; Andrew Gaffney catalyst, modules/catalyst/arch/__init__.py, +modules/catalyst/output.py, modules/catalyst/support.py, modules/catalyst/target/__init__.py, diff --git a/catalyst b/catalyst index 367a91c1..c6acf130 100755 --- a/catalyst +++ b/catalyst @@ -167,7 +167,7 @@ def verify_digest_and_hash_functions(): print print "Catalyst aborting...." sys.exit(2) - if find_binary(hash_map[i][1]) == None: + if catalyst.util.find_binary(hash_map[i][1]) == None: print print "digest="+i print "\tThe "+hash_map[i][1]+\ @@ -185,7 +185,7 @@ def verify_digest_and_hash_functions(): print print "Catalyst aborting...." sys.exit(2) - if find_binary(hash_map[conf_values["hash_function"]][1]) == None: + if catalyst.util.find_binary(hash_map[conf_values["hash_function"]][1]) == None: print print "hash_function="+conf_values["hash_function"] print "\tThe "+hash_map[conf_values["hash_function"]][1]+\ diff --git a/modules/catalyst/support.py b/modules/catalyst/support.py index ca97c6e0..2a96dae1 100644 --- a/modules/catalyst/support.py +++ b/modules/catalyst/support.py @@ -1,6 +1,7 @@ import sys,string,os,types,re,signal,traceback,time from catalyst.output import warn +import catalyst.util #import md5,sha selinux_capable = False @@ -265,19 +266,6 @@ class LockInUse(Exception): print "!!! catalyst lock file in use: "+message print -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 spawn_bash(mycommand,env={},debug=False,opt_name=None,**keywords): """spawn mycommand as an arguement to bash""" args=[BASH_BINARY] @@ -373,7 +361,7 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur if not os.access(myc, os.X_OK): if not path_lookup: return None - myc = find_binary(myc) + myc = catalyst.util.find_binary(myc) if myc == None: return None mypid=[] diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index 9b191326..8b6c63b7 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -21,3 +21,16 @@ def load_module(name): return sys.modules[name] except Exception: return None + +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 + -- 2.26.2