Spaces:
Paused
Paused
Update pc_agent.py
Browse files- pc_agent.py +0 -3
pc_agent.py
CHANGED
|
@@ -1,15 +1,12 @@
|
|
| 1 |
-
# [سيرفر الكمبيوتر] pc_agent.py
|
| 2 |
import subprocess, os, tempfile, shutil
|
| 3 |
from pathlib import Path
|
| 4 |
|
| 5 |
WORKSPACE = Path(tempfile.mkdtemp(prefix="zai_workspace_"))
|
| 6 |
|
| 7 |
def run_command(cmd: str, timeout: int = 30) -> dict:
|
| 8 |
-
# تنظيف الأوامر الخطرة للأمان
|
| 9 |
dangerous = ["rm -rf /", "mkfs", "dd if=", "shutdown", "reboot", "curl", "wget"]
|
| 10 |
if any(d in cmd.lower() for d in dangerous):
|
| 11 |
return {"output": "⛔ أمر غير مسموح به لأسباب أمنية.", "error": True}
|
| 12 |
-
|
| 13 |
try:
|
| 14 |
result = subprocess.run(
|
| 15 |
cmd, shell=True, cwd=str(WORKSPACE),
|
|
|
|
|
|
|
| 1 |
import subprocess, os, tempfile, shutil
|
| 2 |
from pathlib import Path
|
| 3 |
|
| 4 |
WORKSPACE = Path(tempfile.mkdtemp(prefix="zai_workspace_"))
|
| 5 |
|
| 6 |
def run_command(cmd: str, timeout: int = 30) -> dict:
|
|
|
|
| 7 |
dangerous = ["rm -rf /", "mkfs", "dd if=", "shutdown", "reboot", "curl", "wget"]
|
| 8 |
if any(d in cmd.lower() for d in dangerous):
|
| 9 |
return {"output": "⛔ أمر غير مسموح به لأسباب أمنية.", "error": True}
|
|
|
|
| 10 |
try:
|
| 11 |
result = subprocess.run(
|
| 12 |
cmd, shell=True, cwd=str(WORKSPACE),
|