mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
remove now unused run_legacy_script()
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
"""
|
||||
Helper functions for executing external programs.
|
||||
"""
|
||||
from typing import Any, Union, Optional, Mapping, IO
|
||||
from typing import Any, Optional, Mapping, IO
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import os
|
||||
@@ -15,38 +15,12 @@ import subprocess
|
||||
import urllib.request as urlrequest
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from nominatim.config import Configuration
|
||||
from nominatim.typing import StrPath
|
||||
from nominatim.version import NOMINATIM_VERSION
|
||||
from nominatim.db.connection import get_pg_env
|
||||
|
||||
LOG = logging.getLogger()
|
||||
|
||||
def run_legacy_script(script: StrPath, *args: Union[int, str],
|
||||
config: Configuration,
|
||||
throw_on_fail: bool = False) -> int:
|
||||
""" Run a Nominatim PHP script with the given arguments.
|
||||
|
||||
Returns the exit code of the script. If `throw_on_fail` is True
|
||||
then throw a `CalledProcessError` on a non-zero exit.
|
||||
"""
|
||||
cmd = ['/usr/bin/env', 'php', '-Cq',
|
||||
str(config.lib_dir.php / 'admin' / script)]
|
||||
cmd.extend([str(a) for a in args])
|
||||
|
||||
env = config.get_os_env()
|
||||
env['NOMINATIM_DATADIR'] = str(config.lib_dir.data)
|
||||
env['NOMINATIM_SQLDIR'] = str(config.lib_dir.sql)
|
||||
env['NOMINATIM_CONFIGDIR'] = str(config.config_dir)
|
||||
env['NOMINATIM_DATABASE_MODULE_SRC_PATH'] = str(config.lib_dir.module)
|
||||
if not env['NOMINATIM_OSM2PGSQL_BINARY']:
|
||||
env['NOMINATIM_OSM2PGSQL_BINARY'] = str(config.lib_dir.osm2pgsql)
|
||||
|
||||
proc = subprocess.run(cmd, cwd=str(config.project_dir), env=env,
|
||||
check=throw_on_fail)
|
||||
|
||||
return proc.returncode
|
||||
|
||||
def run_api_script(endpoint: str, project_dir: Path,
|
||||
extra_env: Optional[Mapping[str, str]] = None,
|
||||
phpcgi_bin: Optional[Path] = None,
|
||||
|
||||
Reference in New Issue
Block a user