command_runner
Adapted from the Griptape AI Framework documentation.
Source Code in griptape/utils/command_runner.py
@define class CommandRunner: def run(self, command: str) -> BaseArtifact: process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() if len(stderr) == 0: return TextArtifact(stdout.strip().decode()) return ErrorArtifact(f"error: {stderr.strip()}")
run(command)
Source Code in griptape/utils/command_runner.py
def run(self, command: str) -> BaseArtifact: process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() if len(stderr) == 0: return TextArtifact(stdout.strip().decode()) return ErrorArtifact(f"error: {stderr.strip()}")
- On this page
- run(command)
Could this page be better? Report a problem or suggest an addition!