Create executor.py
Browse files- executor.py +17 -0
executor.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
|
| 3 |
+
def execute_command(command_type: str, command_text: str) -> str:
|
| 4 |
+
try:
|
| 5 |
+
if command_type == "open_app":
|
| 6 |
+
if "chrome" in command_text.lower():
|
| 7 |
+
subprocess.Popen(["chrome"])
|
| 8 |
+
return "✅ Opening Chrome..."
|
| 9 |
+
elif command_type == "screenshot":
|
| 10 |
+
return "📸 Simulated screenshot taken."
|
| 11 |
+
elif command_type == "create_file":
|
| 12 |
+
with open("new_file.txt", "w") as f:
|
| 13 |
+
f.write("Hello from your AI assistant.")
|
| 14 |
+
return "✅ File 'new_file.txt' created."
|
| 15 |
+
except Exception as e:
|
| 16 |
+
return f"❌ Error while executing command: {e}"
|
| 17 |
+
return None
|