execPython Python3?

Antworten
SirTux
Beiträge: 566
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: 64
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
SirTux
Beiträge: 566
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