X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/0add25e33500110a36458a0bb3fa292d408d2b85..1f0796778754d8df0dfab9dd01302e26a397f064:/src/nominatim_db/clicmd/add_data.py?ds=inline diff --git a/src/nominatim_db/clicmd/add_data.py b/src/nominatim_db/clicmd/add_data.py index a690435c..580740f1 100644 --- a/src/nominatim_db/clicmd/add_data.py +++ b/src/nominatim_db/clicmd/add_data.py @@ -15,14 +15,13 @@ import asyncio import psutil from .args import NominatimArgs +from ..db.connection import connect +from ..tools.freeze import is_frozen -# Do not repeat documentation of subcommand classes. -# pylint: disable=C0111 -# Using non-top-level imports to avoid eventually unused imports. -# pylint: disable=E0012,C0415 LOG = logging.getLogger() + class UpdateAddData: """\ Add additional data from a file or an online source. @@ -36,7 +35,7 @@ class UpdateAddData: The command can also be used to add external non-OSM data to the database. At the moment the only supported format is TIGER housenumber data. See the online documentation at - https://nominatim.org/release-docs/latest/admin/Import/#installing-tiger-housenumber-data-for-the-us + https://nominatim.org/release-docs/latest/customize/Tiger/ for more information. """ @@ -63,10 +62,14 @@ class UpdateAddData: group2.add_argument('--socket-timeout', dest='socket_timeout', type=int, default=60, help='Set timeout for file downloads') - def run(self, args: NominatimArgs) -> int: from ..tools import add_osm_data + with connect(args.config.get_libpq_dsn()) as conn: + if is_frozen(conn): + print('Database is marked frozen. New data can\'t be added.') + return 1 + if args.tiger_data: return asyncio.run(self._add_tiger_data(args)) @@ -96,7 +99,6 @@ class UpdateAddData: return 0 - async def _add_tiger_data(self, args: NominatimArgs) -> int: from ..tokenizer import factory as tokenizer_factory from ..tools import tiger_data @@ -106,5 +108,5 @@ class UpdateAddData: tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config) return await tiger_data.add_tiger_data(args.tiger_data, args.config, - args.threads or psutil.cpu_count() or 1, + args.threads or psutil.cpu_count() or 1, tokenizer)