mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
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.
22 lines
665 B
Python
22 lines
665 B
Python
"""
|
|
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
|
|
|