implement warming in new cli tool

Adds infrastructure for calling the legacy PHP scripts. As the
CONST_* values cannot be set from the python script, hand the values
in via secret environment variables instead. These are all
temporary hacks for the transition phase to python code.
This commit is contained in:
Sarah Hoffmann
2021-01-13 18:25:15 +01:00
parent ec636111ba
commit 04690ad8c4
5 changed files with 96 additions and 11 deletions

View File

@@ -0,0 +1,21 @@
"""
Helper functions for executing external programs.
"""
from pathlib import Path
import subprocess
def run_legacy_script(script, *args, nominatim_env=None):
""" Run a Nominatim PHP script with the given arguments.
"""
cmd = ['/usr/bin/env', 'php', '-Cq',
nominatim_env.phplib_dir / 'admin' / script]
cmd.extend(args)
env = nominatim_env.config.get_os_env()
env['NOMINATIM_DATADIR'] = str(nominatim_env.data_dir)
env['NOMINATIM_BINDIR'] = str(nominatim_env.data_dir / 'utils')
proc = subprocess.run(cmd, cwd=str(nominatim_env.project_dir), env=env)
return proc.returncode