X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/6e89310a9285f1ad15d8002bf68f578eada367a0..f960a9bf7fd1702b3d66995dd69307bd91d61a08:/src/nominatim_db/tools/replication.py diff --git a/src/nominatim_db/tools/replication.py b/src/nominatim_db/tools/replication.py index f9421bb8..91171deb 100644 --- a/src/nominatim_db/tools/replication.py +++ b/src/nominatim_db/tools/replication.py @@ -16,20 +16,19 @@ import time import types import urllib.request as urlrequest -import requests - -from nominatim_core.errors import UsageError -from nominatim_core.db import status -from nominatim_core.db.connection import Connection, connect +from ..errors import UsageError +from ..db import status +from ..db.connection import Connection, connect, server_version_tuple from .exec_utils import run_osm2pgsql try: from osmium.replication.server import ReplicationServer from osmium import WriteHandler from osmium import version as pyo_version -except ImportError as exc: + import requests +except ModuleNotFoundError as exc: logging.getLogger().critical("pyosmium not installed. Replication functions not available.\n" - "To install pyosmium via pip: pip3 install osmium") + "To install pyosmium via pip: pip install osmium") raise UsageError("replication tools not available") from exc LOG = logging.getLogger() @@ -126,7 +125,8 @@ def update(dsn: str, options: MutableMapping[str, Any], # Read updates into file. with _make_replication_server(options['base_url'], socket_timeout) as repl: outhandler = WriteHandler(str(options['import_file'])) - endseq = repl.apply_diffs(outhandler, startseq + 1, + # tyoing: work around typing bug in pyosmium 4.0 + endseq = repl.apply_diffs(outhandler, startseq + 1, # type: ignore[arg-type] max_size=options['max_diff_size'] * 1024) outhandler.close() @@ -155,7 +155,7 @@ def run_osm2pgsql_updates(conn: Connection, options: MutableMapping[str, Any]) - # Consume updates with osm2pgsql. options['append'] = True - options['disable_jit'] = conn.server_version_tuple() >= (11, 0) + options['disable_jit'] = server_version_tuple(conn) >= (11, 0) run_osm2pgsql(options) # Handle deletions