mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-26 08:33:49 +00:00
fixing bash util (#779)
This commit is contained in:
parent
966611bbfa
commit
2e0219cac0
@ -12,15 +12,13 @@ class BashProcess:
|
|||||||
|
|
||||||
def run(self, commands: Union[str, List[str]]) -> str:
|
def run(self, commands: Union[str, List[str]]) -> str:
|
||||||
"""Run commands and return final output."""
|
"""Run commands and return final output."""
|
||||||
outputs = []
|
|
||||||
if isinstance(commands, str):
|
if isinstance(commands, str):
|
||||||
commands = [commands]
|
commands = [commands]
|
||||||
for command in commands:
|
commands = ";".join(commands)
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(command, shell=True).decode()
|
output = subprocess.check_output(commands, shell=True).decode()
|
||||||
if self.strip_newlines:
|
except subprocess.CalledProcessError as error:
|
||||||
output = output.strip()
|
return str(error)
|
||||||
outputs.append(output)
|
if self.strip_newlines:
|
||||||
except subprocess.CalledProcessError as error:
|
output = output.strip()
|
||||||
return str(error)
|
return output
|
||||||
return outputs[-1]
|
|
||||||
|
Loading…
Reference in New Issue
Block a user