Update tools.py
Browse files
tools.py
CHANGED
|
@@ -149,29 +149,7 @@ def read_excel_file(file_path: str) -> Dict[str, Any]:
|
|
| 149 |
except Exception as e:
|
| 150 |
return {"error": f"Failed to read Excel file: {str(e)}"}
|
| 151 |
|
| 152 |
-
|
| 153 |
-
# """Execute Python code safely with subprocess"""
|
| 154 |
-
# try:
|
| 155 |
-
# # Run in isolated subprocess with timeout
|
| 156 |
-
# result = subprocess.run(
|
| 157 |
-
# ['python', file_path],
|
| 158 |
-
# capture_output=True,
|
| 159 |
-
# text=True,
|
| 160 |
-
# timeout=timeout,
|
| 161 |
-
# cwd=tempfile.gettempdir() # Run in temp directory
|
| 162 |
-
# )
|
| 163 |
-
|
| 164 |
-
# if result.returncode == 0:
|
| 165 |
-
# return result.stdout.strip()
|
| 166 |
-
# else:
|
| 167 |
-
# return f"Error: {result.stderr}"
|
| 168 |
-
|
| 169 |
-
# except subprocess.TimeoutExpired:
|
| 170 |
-
# return "Error: Code execution timed out"
|
| 171 |
-
# except Exception as e:
|
| 172 |
-
# return f"Error executing code: {str(e)}"
|
| 173 |
-
|
| 174 |
-
def execute_python_code(file_path: str, timeout: int = 30) -> str:
|
| 175 |
"""Execute Python code safely with subprocess"""
|
| 176 |
try:
|
| 177 |
# Check if file exists, if not try common locations
|
|
|
|
| 149 |
except Exception as e:
|
| 150 |
return {"error": f"Failed to read Excel file: {str(e)}"}
|
| 151 |
|
| 152 |
+
def execute_python_code(file_path: str, timeout: int = 60) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
"""Execute Python code safely with subprocess"""
|
| 154 |
try:
|
| 155 |
# Check if file exists, if not try common locations
|