2 Helper functions for executing external programs.
6 def run_legacy_script(script, *args, nominatim_env=None, throw_on_fail=False):
7 """ Run a Nominatim PHP script with the given arguments.
9 Returns the exit code of the script. If `throw_on_fail` is True
10 then throw a `CalledProcessError` on a non-zero exit.
12 cmd = ['/usr/bin/env', 'php', '-Cq',
13 nominatim_env.phplib_dir / 'admin' / script]
14 cmd.extend([str(a) for a in args])
16 env = nominatim_env.config.get_os_env()
17 env['NOMINATIM_DATADIR'] = str(nominatim_env.data_dir)
18 env['NOMINATIM_BINDIR'] = str(nominatim_env.data_dir / 'utils')
19 if not env['NOMINATIM_DATABASE_MODULE_PATH']:
20 env['NOMINATIM_DATABASE_MODULE_PATH'] = nominatim_env.module_dir
21 if not env['NOMINATIM_OSM2PGSQL_BINARY']:
22 env['NOMINATIM_OSM2PGSQL_BINARY'] = nominatim_env.osm2pgsql_path
24 proc = subprocess.run(cmd, cwd=str(nominatim_env.project_dir), env=env,
27 return proc.returncode