blux-ca / ca /evaluator /advanced /bash_evaluator.py
Justadudeinspace
restructure and upgrade all ca python files
2c5ae19
raw
history blame contribute delete
529 Bytes
import subprocess
class BashEvaluator:
"""
Evaluates shell/Bash commands in a safe subprocess.
"""
def __init__(self, name="bash_evaluator"):
self.name = name
def evaluate(self, command_str):
try:
result = subprocess.run(command_str, shell=True, capture_output=True, text=True, timeout=5)
return {"success": result.returncode == 0, "stdout": result.stdout, "stderr": result.stderr}
except Exception as e:
return {"success": False, "error": str(e)}