From: Sarah Hoffmann Date: Thu, 20 Jul 2023 10:14:19 +0000 (+0200) Subject: remove now unused run_legacy_script() X-Git-Tag: v4.3.0~48^2~5 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/4cd0a4ced47c1e034194956a01418fa5884ddc3c remove now unused run_legacy_script() --- diff --git a/nominatim/tools/exec_utils.py b/nominatim/tools/exec_utils.py index 566ac06e..c8de8c7d 100644 --- a/nominatim/tools/exec_utils.py +++ b/nominatim/tools/exec_utils.py @@ -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, diff --git a/test/python/cli/conftest.py b/test/python/cli/conftest.py index 09bfd353..d4e1118e 100644 --- a/test/python/cli/conftest.py +++ b/test/python/cli/conftest.py @@ -59,13 +59,6 @@ def cli_call(src_dir): return _call_nominatim -@pytest.fixture -def mock_run_legacy(monkeypatch): - mock = MockParamCapture() - monkeypatch.setattr(nominatim.cli, 'run_legacy_script', mock) - return mock - - @pytest.fixture def mock_func_factory(monkeypatch): def get_mock(module, func): diff --git a/test/python/tools/test_exec_utils.py b/test/python/tools/test_exec_utils.py index f73aec30..792c24c8 100644 --- a/test/python/tools/test_exec_utils.py +++ b/test/python/tools/test_exec_utils.py @@ -16,75 +16,6 @@ from nominatim.config import Configuration import nominatim.tools.exec_utils as exec_utils import nominatim.paths -class TestRunLegacyScript: - - @pytest.fixture(autouse=True) - def setup_nominatim_env(self, tmp_path, monkeypatch): - tmp_phplib_dir = tmp_path / 'phplib' - tmp_phplib_dir.mkdir() - (tmp_phplib_dir / 'admin').mkdir() - - monkeypatch.setattr(nominatim.paths, 'PHPLIB_DIR', tmp_phplib_dir) - - self.phplib_dir = tmp_phplib_dir - self.config = Configuration(tmp_path) - self.config.set_libdirs(module='.', osm2pgsql='default_osm2pgsql', - php=tmp_phplib_dir) - - - def mk_script(self, code): - codefile = self.phplib_dir / 'admin' / 't.php' - codefile.write_text('