Fix grep_files when some file doesn't match given pattern
Change-Id: Iff8f29d3a083398e5cd4ec5595fc6d7dc39894fe
This commit is contained in:
parent
8481c476c4
commit
da63824b88
@ -48,23 +48,26 @@ def grep(pattern: str,
|
|||||||
raise ValueError("command and files can't be both empty or None")
|
raise ValueError("command and files can't be both empty or None")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = sh.execute(command_line,
|
stdout = sh.execute(command_line,
|
||||||
ssh_client=ssh_client,
|
ssh_client=ssh_client,
|
||||||
**execute_params)
|
**execute_params).stdout
|
||||||
except sh.ShellCommandFailed as ex:
|
except sh.ShellCommandFailed as ex:
|
||||||
if ex.exit_status > 1:
|
if ex.exit_status > 1:
|
||||||
# Some unknown problem occurred
|
# Some unknown problem occurred
|
||||||
raise
|
raise
|
||||||
else:
|
stdout = ex.stdout
|
||||||
|
|
||||||
output_lines: typing.List[str] = [
|
output_lines: typing.List[str] = [
|
||||||
line
|
line
|
||||||
for line in result.stdout.splitlines()
|
for line in stdout.splitlines()
|
||||||
if blank_lines or line.strip()]
|
if blank_lines or line.strip()]
|
||||||
if output_lines:
|
if output_lines:
|
||||||
return output_lines
|
return output_lines
|
||||||
|
|
||||||
|
login = ssh_client.login if ssh_client else None
|
||||||
raise NoMatchingLinesFound(pattern=pattern,
|
raise NoMatchingLinesFound(pattern=pattern,
|
||||||
files=files,
|
files=files,
|
||||||
login=ssh_client and ssh_client.login or None)
|
login=login)
|
||||||
|
|
||||||
|
|
||||||
def grep_files(pattern: str,
|
def grep_files(pattern: str,
|
||||||
|
Loading…
Reference in New Issue
Block a user