Initial commit

This commit is contained in:
2025-04-09 09:34:15 +02:00
commit c19fb93ec5
47 changed files with 5174 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
"""
Command execution for the Edison application.
"""
import subprocess
import logging
from edison.utils import validation
logger = logging.getLogger(__name__)
def execute_command(shell, command):
"""
Execute a shell command.
Args:
shell (str): The shell to use.
command (str): The command to execute.
Returns:
subprocess.CompletedProcess: The result of the command execution.
Raises:
subprocess.CalledProcessError: If the command execution fails.
"""
if validation.is_dangerous_command(command):
logger.warning(f"Potentially dangerous command detected: {command}")
# We still allow execution but log a warning
try:
if shell == "powershell.exe":
result = subprocess.run([shell, "/c", command], shell=False, check=True)
else:
# Unix: /bin/bash /bin/zsh: uses -c both Ubuntu and macOS should work, others might not
result = subprocess.run([shell, "-c", command], shell=False, check=True)
logger.debug(f"Command executed successfully: {command}")
return result
except subprocess.CalledProcessError as e:
logger.error(f"Command execution failed: {e}")
raise