This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
server-personification/lib/openai/bash.py

12 lines
385 B
Python
Raw Normal View History

2024-01-20 15:01:25 -07:00
import json
import subprocess
def func_run_bash(command_data: str):
j = json.loads(command_data)
command = j.get('command')
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
stdout, stderr = process.communicate()
return_code = process.returncode
return stdout.decode('utf-8'), stderr.decode('utf-8'), return_code