execPython Python3?

Antworten
SirTux
Beiträge: 607
Registriert: 05 Feb 2011, 18:37

execPython Python3?

Beitrag von SirTux »

Hi,

Sind die execPython-Sektionen noch aktuell mit Unterstützung von Python 3? Das Beispiel im Handbuch sieht mir arg nach Python3 aus.

Viele Grüße,
Stefan
Benutzeravatar
j.werner
uib-Team
Beiträge: 86
Registriert: 08 Okt 2019, 13:32

Re: execPython Python3?

Beitrag von j.werner »

Hallo Stefan,
verwende bitte dafür die verallgemeinerte execWith Sektion:

ExecWith_SECTION PROGRAM PROGRAMPARAS pass PASSPARAS winst WINSTOPTS

Details im Handbuch

Grüße Jan


Vielen Dank für die Nutzung von opsi. Im Forum ist unser Support begrenzt.

Für den professionellen Einsatz und individuelle Beratung empfehlen wir einen Support-Vertrag und eine Schulung.
Gerne informieren wir Sie zu unserem Angebot.

uib GmbH
Telefon: +49 6131 27561 0
E-Mail: sales@uib.de


SirTux
Beiträge: 607
Registriert: 05 Feb 2011, 18:37

Re: execPython Python3?

Beitrag von SirTux »

Danke funktioniert. Hier ein Beispiel mit jinja-Templating:

Code: Alles auswählen

execWith_jinja_template "python3"
if not("0" = getLastExitCode)
  Message "failed execWith_jinja_template"
  LogError "failed execWith_jinja_template"
  isFatalError "execWith_jinja_template"
endif

[execWith_jinja_tepmlplate]
import pathlib
from jinja2 import Environment, FileSystemLoader, select_autoescape
env = Environment(loader=FileSystemLoader("%ScriptPath%"))
template = env.get_template("tepmplatename.template")
output = template.render(bla="$bla$", blub="blub")
cfile = pathlib.Path("/path/to/configfile.conf")
cfile.write_text(output)
Antworten