aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/plugins/__init__.py2
-rw-r--r--sos/utilities.py5
-rw-r--r--tests/utilities_tests.py4
3 files changed, 9 insertions, 2 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index b9be263a..3b12fd6b 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -394,7 +394,7 @@ class Plugin(object):
def fileGrep(self, regexp, *fnames):
"""Returns lines matched in fnames, where fnames can either be pathnames to files
to grep through or open file objects to grep through line by line"""
- return grep(regexp, fnames)
+ return grep(regexp, *fnames)
def mangleCommand(self, exe):
# FIXME: this can be improved
diff --git a/sos/utilities.py b/sos/utilities.py
index e705ae7d..e0d57dfe 100644
--- a/sos/utilities.py
+++ b/sos/utilities.py
@@ -42,7 +42,10 @@ import time
def fileobj(path_or_file, mode='r'):
if isinstance(path_or_file, basestring):
- return open(path_or_file, mode)
+ try:
+ return open(path_or_file, mode)
+ except:
+ return closing(StringIO())
else:
return closing(path_or_file)
diff --git a/tests/utilities_tests.py b/tests/utilities_tests.py
index fbfc9a55..7eecc01a 100644
--- a/tests/utilities_tests.py
+++ b/tests/utilities_tests.py
@@ -23,6 +23,10 @@ class GrepTest(unittest.TestCase):
matches = grep(".*unittest$", open(__file__.replace(".pyc", ".py")))
self.assertEquals(matches, ['import unittest\n'])
+ def test_grep_multiple_files(self):
+ matches = grep(".*unittest$", __file__.replace(".pyc", ".py"), "does_not_exist.txt")
+ self.assertEquals(matches, ['import unittest\n'])
+
class DirTreeTest(unittest.TestCase):