Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merge pull request #244 from HubbleStack/develop
Browse files Browse the repository at this point in the history
Merge to master (prep for v2016.9.1)
  • Loading branch information
basepi authored Sep 6, 2016
2 parents 3e2b066 + 41a2776 commit 45e372d
Show file tree
Hide file tree
Showing 3 changed files with 834 additions and 13 deletions.
22 changes: 13 additions & 9 deletions hubblestack_nova_modules/grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def _get_tags(data):

def _grep(path,
pattern,
*opts):
*args):
'''
Grep for a string in the specified file
Expand Down Expand Up @@ -321,15 +321,19 @@ def _grep(path,
'''
path = os.path.expanduser(path)

split_opts = []
for opt in opts:
try:
opt = salt.utils.shlex_split(opt)
except AttributeError:
opt = salt.utils.shlex_split(str(opt))
split_opts.extend(opt)
if args:
options = ' '.join(args)
else:
options = ''
cmd = (
r'''grep {options} {pattern} {path}'''
.format(
options=options,
pattern=pattern,
path=path,
)
)

cmd = ['grep'] + split_opts + [pattern, path]
try:
ret = __salt__['cmd.run_all'](cmd, python_shell=False, ignore_retcode=True)
except (IOError, OSError) as exc:
Expand Down
Loading

0 comments on commit 45e372d

Please sign in to comment.