import subprocess import platform class PowerShellExecutor: @staticmethod def execute(command): # Detetar o sistema operativo para escolher o interpretador if platform.system() == "Windows": shell_cmd = ["powershell", "-Command", command] else: # Em Linux (Hugging Face), usamos bash ou sh shell_cmd = ["/bin/bash", "-c", command] try: result = subprocess.run( shell_cmd, capture_output=True, text=True, encoding="utf-8" ) return { "stdout": result.stdout, "stderr": result.stderr, "exit_code": result.returncode } except Exception as e: return { "stdout": "", "stderr": str(e), "exit_code": -1 }