comp.lang.ada
 help / color / mirror / Atom feed
From: "Rego, P." <pvrego@gmail.com>
Subject: Running a simple Python from Ada program
Date: Fri, 3 Apr 2020 09:57:14 -0700 (PDT)
Date: 2020-04-03T09:57:14-07:00	[thread overview]
Message-ID: <e5076a57-5f9d-43eb-bac9-1bf016237389@googlegroups.com> (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

             reply	other threads:[~2020-04-03 16:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03 16:57 Rego, P. [this message]
2020-04-03 17:35 ` Running a simple Python from Ada program 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
replies disabled

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