Skip to content

Commit 9f3b70d

Browse files
committed
Don't fail if an output filter doesn't have groups
Previously, any output filter patterns needed to have at least one group indicated by a set of parentheses. This didn't take into account the use case where the user doesn't care about capturing output, only wants to verify that certain output existed. This fixes that shortcoming.
1 parent 8564de8 commit 9f3b70d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

vagrant/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,15 +1015,19 @@ def _filter_vagrant_command(self, args, output_filter):
10151015

10161016
# Parse command output for the specified filters. Method used depends on version of Python.
10171017
# See http://stackoverflow.com/questions/2715847/python-read-streaming-input-from-subprocess-communicate#17698359
1018-
if not py3: # Python < 3.0
1018+
if not py3: # Python 2.x
10191019
p = subprocess.Popen(**sp_args)
10201020
with p.stdout:
10211021
for line in iter(p.stdout.readline, b''):
10221022
pop_key = None
10231023
for f in output_filter.keys():
10241024
m = re.search(output_filter[f]['pat'], line)
10251025
if m:
1026-
filter_results[f] = m.group(output_filter[f]['group'])
1026+
try:
1027+
filter_results[f] = m.group(output_filter[f]['group'])
1028+
except IndexError:
1029+
# User must have not included parenthases in their pattern
1030+
pass
10271031
# No need to search for this pattern again in future lines
10281032
pop_key = f
10291033
break
@@ -1038,7 +1042,11 @@ def _filter_vagrant_command(self, args, output_filter):
10381042
for f in output_filter.keys():
10391043
m = re.search(output_filter[f]['pat'], line)
10401044
if m:
1041-
filter_results[f] = m.group(output_filter[f]['group'])
1045+
try:
1046+
filter_results[f] = m.group(output_filter[f]['group'])
1047+
except IndexError:
1048+
# User must have not included parenthases in their pattern
1049+
pass
10421050
# No need to search for this pattern again in future lines
10431051
pop_key = f
10441052
break

0 commit comments

Comments
 (0)