Update tests.py
Browse files
tests.py
CHANGED
|
@@ -103,7 +103,7 @@ def run(cmd, timeout_sec,forever_cmd):
|
|
| 103 |
|
| 104 |
Parent.sendline(command)
|
| 105 |
Parent.readline().decode()
|
| 106 |
-
return str(Parent.readline().decode()) + "[INFO] The opened ports can be externally accessed at https://suitable-liked-ibex.ngrok-free.app/ "
|
| 107 |
t=time.time()
|
| 108 |
child = pexpect.spawn("bash")
|
| 109 |
output=""
|
|
@@ -244,10 +244,8 @@ def run_code(python_packages:str,filename: str, code: str,start_cmd:str,forever_
|
|
| 244 |
@mcp.tool()
|
| 245 |
def run_code_files(start_cmd:str,forever_cmd:str) -> dict:
|
| 246 |
"""Executes a shell command to run code files from /app/code_interpreter.
|
| 247 |
-
|
| 248 |
Runs the given `start_cmd`. The execution behavior depends on `forever_cmd`.
|
| 249 |
Any server/website started should use port 1337.
|
| 250 |
-
|
| 251 |
Args:
|
| 252 |
start_cmd (str): The shell command to execute the code.
|
| 253 |
(e.g., ``python /app/code_interpreter/app.py``).
|
|
@@ -255,15 +253,13 @@ def run_code_files(start_cmd:str,forever_cmd:str) -> dict:
|
|
| 255 |
forever_cmd (str): Execution mode.
|
| 256 |
- ``'true'``: Runs indefinitely (for servers/websites).
|
| 257 |
- ``'false'``: Runs up to 300s, captures output.
|
| 258 |
-
|
| 259 |
Returns:
|
| 260 |
dict: A dictionary containing:
|
| 261 |
- ``'output'`` (str): Captured stdout (mainly when forever_cmd='false').
|
| 262 |
- ``'Files_download_link'`` (Any): Links/identifiers for downloadable files.
|
| 263 |
-
|
| 264 |
Notes:
|
| 265 |
- After execution, embed a download link (or display images/gifs/videos directly in markdown format) in your response.
|
| 266 |
-
|
| 267 |
"""
|
| 268 |
global files_list
|
| 269 |
|
|
@@ -284,19 +280,16 @@ def run_code_files(start_cmd:str,forever_cmd:str) -> dict:
|
|
| 284 |
@mcp.tool()
|
| 285 |
def run_shell_command(cmd:str,forever_cmd:str) -> dict:
|
| 286 |
"""Executes a shell command in a sandboxed Alpine Linux environment.
|
| 287 |
-
|
| 288 |
Runs the provided `cmd` string within a bash shell. Commands are executed
|
| 289 |
relative to the `/app/code_interpreter/` working directory by default.
|
| 290 |
The execution behavior (indefinite run vs. timeout) is controlled by
|
| 291 |
the `forever_cmd` parameter.
|
| 292 |
-
|
| 293 |
Important Environment Notes:
|
| 294 |
- The execution environment is **Alpine Linux**. Commands should be
|
| 295 |
compatible (e.g., `apk add` instead of `apt-get install`).
|
| 296 |
- `sudo` is not available and not required.
|
| 297 |
- Standard bash features like `&&`, `||`, pipes (`|`), etc., are supported.
|
| 298 |
- When installing python packages , add an argument --break-system-packages to the pip install command.
|
| 299 |
-
|
| 300 |
Args:
|
| 301 |
cmd (str): The shell command to execute.
|
| 302 |
Example: ``mkdir test_dir && ls -l``
|
|
@@ -307,7 +300,6 @@ def run_shell_command(cmd:str,forever_cmd:str) -> dict:
|
|
| 307 |
- ``'false'``: Runs the command until completion or
|
| 308 |
a 300-second timeout, whichever comes first.
|
| 309 |
Captures standard output.
|
| 310 |
-
|
| 311 |
Returns:
|
| 312 |
dict: A dictionary containing the execution results:
|
| 313 |
- ``'output'`` (str): The captured standard output (stdout) and potentially
|
|
@@ -354,6 +346,7 @@ def read_excel_file(filename) -> dict:
|
|
| 354 |
"""Reads the contents of an excel file.Returns a dict with key :value pair = cell location:cell content.Always run this command first , when working with excels.The excel file is automatically present in the /app/code_interpreter directory. """
|
| 355 |
global destination_dir
|
| 356 |
transfer_files2()
|
|
|
|
| 357 |
|
| 358 |
workbook = openpyxl.load_workbook(os.path.join(destination_dir, filename))
|
| 359 |
|
|
|
|
| 103 |
|
| 104 |
Parent.sendline(command)
|
| 105 |
Parent.readline().decode()
|
| 106 |
+
return str(Parent.readline().decode()) + "[INFO] The opened ports can be externally accessed at https://suitable-liked-ibex.ngrok-free.app/ (ONLY if the website is running successfully)"
|
| 107 |
t=time.time()
|
| 108 |
child = pexpect.spawn("bash")
|
| 109 |
output=""
|
|
|
|
| 244 |
@mcp.tool()
|
| 245 |
def run_code_files(start_cmd:str,forever_cmd:str) -> dict:
|
| 246 |
"""Executes a shell command to run code files from /app/code_interpreter.
|
|
|
|
| 247 |
Runs the given `start_cmd`. The execution behavior depends on `forever_cmd`.
|
| 248 |
Any server/website started should use port 1337.
|
|
|
|
| 249 |
Args:
|
| 250 |
start_cmd (str): The shell command to execute the code.
|
| 251 |
(e.g., ``python /app/code_interpreter/app.py``).
|
|
|
|
| 253 |
forever_cmd (str): Execution mode.
|
| 254 |
- ``'true'``: Runs indefinitely (for servers/websites).
|
| 255 |
- ``'false'``: Runs up to 300s, captures output.
|
|
|
|
| 256 |
Returns:
|
| 257 |
dict: A dictionary containing:
|
| 258 |
- ``'output'`` (str): Captured stdout (mainly when forever_cmd='false').
|
| 259 |
- ``'Files_download_link'`` (Any): Links/identifiers for downloadable files.
|
|
|
|
| 260 |
Notes:
|
| 261 |
- After execution, embed a download link (or display images/gifs/videos directly in markdown format) in your response.
|
| 262 |
+
- When editing and subsequently re-executing the server with the forever_cmd='true' setting, the previous server instance will be automatically terminated, and the updated server will commence operation. This functionality negates the requirement for manual process termination commands such as pkill node.
|
| 263 |
"""
|
| 264 |
global files_list
|
| 265 |
|
|
|
|
| 280 |
@mcp.tool()
|
| 281 |
def run_shell_command(cmd:str,forever_cmd:str) -> dict:
|
| 282 |
"""Executes a shell command in a sandboxed Alpine Linux environment.
|
|
|
|
| 283 |
Runs the provided `cmd` string within a bash shell. Commands are executed
|
| 284 |
relative to the `/app/code_interpreter/` working directory by default.
|
| 285 |
The execution behavior (indefinite run vs. timeout) is controlled by
|
| 286 |
the `forever_cmd` parameter.
|
|
|
|
| 287 |
Important Environment Notes:
|
| 288 |
- The execution environment is **Alpine Linux**. Commands should be
|
| 289 |
compatible (e.g., `apk add` instead of `apt-get install`).
|
| 290 |
- `sudo` is not available and not required.
|
| 291 |
- Standard bash features like `&&`, `||`, pipes (`|`), etc., are supported.
|
| 292 |
- When installing python packages , add an argument --break-system-packages to the pip install command.
|
|
|
|
| 293 |
Args:
|
| 294 |
cmd (str): The shell command to execute.
|
| 295 |
Example: ``mkdir test_dir && ls -l``
|
|
|
|
| 300 |
- ``'false'``: Runs the command until completion or
|
| 301 |
a 300-second timeout, whichever comes first.
|
| 302 |
Captures standard output.
|
|
|
|
| 303 |
Returns:
|
| 304 |
dict: A dictionary containing the execution results:
|
| 305 |
- ``'output'`` (str): The captured standard output (stdout) and potentially
|
|
|
|
| 346 |
"""Reads the contents of an excel file.Returns a dict with key :value pair = cell location:cell content.Always run this command first , when working with excels.The excel file is automatically present in the /app/code_interpreter directory. """
|
| 347 |
global destination_dir
|
| 348 |
transfer_files2()
|
| 349 |
+
transfer_files()
|
| 350 |
|
| 351 |
workbook = openpyxl.load_workbook(os.path.join(destination_dir, filename))
|
| 352 |
|