From fd9437277e14e1911b2c011fb7dabf6fcbb2d8c4 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Mon, 19 Aug 2024 16:36:09 +0200 Subject: [PATCH] import requests library later than osmium requests will usually be pulled in by osmium and is therefore not a direct dependency of nominatim. Make sure it is only used, when osmium is present. --- src/nominatim_db/tools/replication.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/nominatim_db/tools/replication.py b/src/nominatim_db/tools/replication.py index 2b1d444f..eb031f39 100644 --- a/src/nominatim_db/tools/replication.py +++ b/src/nominatim_db/tools/replication.py @@ -16,8 +16,6 @@ import time import types import urllib.request as urlrequest -import requests - from ..errors import UsageError from ..db import status from ..db.connection import Connection, connect, server_version_tuple @@ -27,9 +25,10 @@ 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() -- 2.39.5