1:- module(system_ssardina,
    2    [
    3        run_python/3
    4    ]).    5
    6:- use_module(library(http/http_open)).    7:- use_module(library(socket)).    8:- use_module(library(debug)).
 run_python(+Script, +Args, -Status) is det
Executes a Python script with the given arguments and captures its output and error streams. Script: Path to the Python script to execute. Args: List of arguments to pass to the Python script. Status: The exit status of the Python process.

e.g., run_python('script.py', ['arg1', 'arg2'], Status).

   19run_python(Script, Args, Status) :-
   20	(exists_file(Script)
   21    ->  true
   22    ;
   23	    throw(error(existence_error(file, Script), _))
   24    ),
   25	process_create(path(python),
   26		[Script|Args],
   27		[stdout(pipe(Out)), stderr(pipe(Err)), process(PID)]),
   28	read_string(Out, _, StdOut),
   29	read_string(Err, _, StdErr),
   30	% always read before finishing process (output too large for OS buffers)
   31	close(Out),
   32	close(Err),
   33	process_wait(PID, Status),
   34	debug(debug, "Python ID and status: ~d - ~w~n", [PID, Status]),
   35	debug(debug, "Python output: ~s~n", [StdOut]),
   36	debug(debug, "Python error: ~s~n", [StdErr])