summaryrefslogtreecommitdiff
path: root/client/bin/autotest_utils.py
diff options
context:
space:
mode:
authormbligh <mbligh@592f7852-d20e-0410-864c-8624ca9c26a4>2007-12-04 22:50:14 +0000
committermbligh <mbligh@592f7852-d20e-0410-864c-8624ca9c26a4>2007-12-04 22:50:14 +0000
commit9921ccaac7e25c0c3f908a03f410ee08fc969768 (patch)
tree81ddb53cb023238ba2cb4cc6bb67c046484fc206 /client/bin/autotest_utils.py
parent22a001a592561fcaf2bcea07bfad09de0f737ed8 (diff)
Add locate() function to autotest_utils. Acts much like:
find . -name 'pattern' and returns a list of files matching the pattern. Signed-off-by: Ryan Harper <ryanh@us.ibm.com> git-svn-id: svn://test.kernel.org/autotest/trunk@1034 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'client/bin/autotest_utils.py')
-rwxr-xr-xclient/bin/autotest_utils.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/client/bin/autotest_utils.py b/client/bin/autotest_utils.py
index d463a201..e1714948 100755
--- a/client/bin/autotest_utils.py
+++ b/client/bin/autotest_utils.py
@@ -3,7 +3,7 @@
import os,os.path,shutil,urllib,sys,signal,commands,pickle,glob,statvfs
from common.error import *
-import re,string
+import re,string,fnmatch
def grep(pattern, file):
"""
@@ -561,6 +561,14 @@ def write_keyval(path, dictionary):
keyval.close()
+# much like find . -name 'pattern'
+def locate(pattern, root=os.getcwd()):
+ for path, dirs, files in os.walk(root):
+ for f in [os.path.abspath(os.path.join(path, f))
+ for f in files if fnmatch.fnmatch(f, pattern)]:
+ yield f
+
+
def freespace(path):
# Find free space available in bytes
s = os.statvfs(path)