mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
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:
21
nominatim/admin/exec_utils.py
Normal file
21
nominatim/admin/exec_utils.py
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user