comp.lang.ada
 help / color / mirror / Atom feed
* Running a simple Python from Ada program
@ 2020-04-03 16:57 Rego, P.
  2020-04-03 17:35 ` Dmitry A. Kazakov
  2020-04-04 10:44 ` fabien.chouteau
  0 siblings, 2 replies; 10+ messages in thread
From: Rego, P. @ 2020-04-03 16:57 UTC (permalink / raw)


Does someone would have a simplest as possible way to run a Python script from the Ada project?

The Python script in this case only has a print in a loop, with a sleep, so each iteration it should print the arguments. 

The Python script I'm using is
import sys
import time

for index in range(10):
    print(sys.argv)
    time.sleep(1)

On approach I am trying is running this one as a batch script, so using 
import sys
import time

with Text_IO;
with Interfaces.C; use Interfaces.C;
procedure systest2 is
   function Sys (Arg : Char_Array) return Integer;
   pragma Import(C, Sys, "system");
   Ret_Val : Integer;
begin
   Ret_Val := Sys(To_C("python testpy.py arg1 arg2"));
   
end systest2;

The problem is that the execution blocks the script, meaning that the Python printouts are only printed at the end of the execution, at once. 

I know that there is a solution (to run Python from Ada) based on GNATCOLL, but I couldn't find any example to run it.

Tnx

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-04-04 10:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 16:57 Running a simple Python from Ada program Rego, P.
2020-04-03 17:35 ` Dmitry A. Kazakov
2020-04-03 19:05   ` Rego, P.
2020-04-03 19:19     ` Rego, P.
2020-04-03 20:06       ` Dmitry A. Kazakov
2020-04-04  1:48       ` Dennis Lee Bieber
2020-04-03 23:49   ` Mikhail Terekhov
2020-04-04  2:55     ` Nasser M. Abbasi
2020-04-04  8:15     ` Dmitry A. Kazakov
2020-04-04 10:44 ` fabien.chouteau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox