Ciao,
Attualmente sto sviluppando un componente aggiuntivo JMP che si basa su script Python incorporati.
All'avvio, il componente aggiuntivo installa i pacchetti Python richiesti (utilizzando un repository wheel locale) prima di eseguire qualsiasi codice Python.
Il problema che riscontro è che, quando il componente aggiuntivo viene avviato per la prima volta, a volte non riesce a eseguire le funzioni Python incorporate definite nei file inviati subito dopo l'installazione del pacchetto.
It looks like JMP continues executing the script prima che il processo di installazione di PowerShell sia effettivamente completato.
The error I get is that Python cannot find one of the functions defined in the two Python Submit File calls.
Dopo la prima installazione riuscita, tutto funziona correttamente (probabilmente perché i pacchetti sono già presenti e gli script vengono caricati correttamente).
How can I make sure that JMP waits until the PowerShell installation process is fully completed before running Python Submit File()?
Ecco la parte rilevante del mio codice:
strPathjpip = dest_path || "\jpip.bat";
If( !File Exists( strPathjpip ),
Python Send( dest_path );
Python Submit( "
import jmp
import jmputils
jmputils.create_jpip(dest_path)
" );
);
// Build command to run
cmd = Eval Insert( "\[& "^strPathjpip^" install --no-index --find-links "^strPathPythonLibs^" numpy pandas scipy]\" );
Eval( Eval Expr( commands = {Expr( cmd )} ) );
icommand = 0;
// Use Run Program to execute the script
rp = Run Program(
Executable( "PowerShell.exe" ),
ReadFunction( Function( {this}, Write( this << Read ) ) ),
WriteFunction(
Function( {this},
icommand++;
If( icommand <= N Items( commands ),
this << Write( commands[icommand] ),
this << WriteEOF
);
)
)
);
// Include Python scripts
Python Submit File( strPathAddin || "include/PYTHON/exttolint.py" );
Python Submit File( strPathAddin || "include/PYTHON/normtolint.py" );
Un'opzione è usare la funzione Read Function("text")
Names Default To Here(1);
RP = Run Program(
Executable("PING.EXE"/*path probably not needed*/ ),
Options({"-n 5", "localhost"}),
ReadFunction("text")
);
Show(RP);
Write("\!NDONE");