forked from hans/Nominatim
Added --prepare-database flag
This commit is contained in:
committed by
Sarah Hoffmann
parent
ba5ec80611
commit
992703b15e
@@ -88,6 +88,7 @@ class NominatimArgs:
|
|||||||
ignore_errors: bool
|
ignore_errors: bool
|
||||||
index_noanalyse: bool
|
index_noanalyse: bool
|
||||||
no_superuser: bool
|
no_superuser: bool
|
||||||
|
prepare_database: bool
|
||||||
|
|
||||||
# Arguments to 'index'
|
# Arguments to 'index'
|
||||||
boundaries_only: bool
|
boundaries_only: bool
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ class SetupAll:
|
|||||||
help='Do not perform analyse operations during index (expert only)')
|
help='Do not perform analyse operations during index (expert only)')
|
||||||
group3.add_argument('--no-superuser', action='store_true',
|
group3.add_argument('--no-superuser', action='store_true',
|
||||||
help='Do not attempt to create the database')
|
help='Do not attempt to create the database')
|
||||||
|
group3.add_argument('--prepare-database', action='store_true',
|
||||||
|
help='Create the database but do not import any data')
|
||||||
|
|
||||||
|
|
||||||
def run(self, args: NominatimArgs) -> int: # pylint: disable=too-many-statements
|
def run(self, args: NominatimArgs) -> int: # pylint: disable=too-many-statements
|
||||||
@@ -83,11 +85,20 @@ class SetupAll:
|
|||||||
if not files:
|
if not files:
|
||||||
raise UsageError("No input files (use --osm-file).")
|
raise UsageError("No input files (use --osm-file).")
|
||||||
|
|
||||||
if not args.no_superuser:
|
if args.no_superuser and args.prepare_database:
|
||||||
|
raise UsageError("Cannot use --no-superuser and --prepare-database together.")
|
||||||
|
|
||||||
|
complete_import = not args.no_superuser and not args.prepare_database
|
||||||
|
|
||||||
|
if args.prepare_database or complete_import:
|
||||||
LOG.warning('Creating database')
|
LOG.warning('Creating database')
|
||||||
database_import.setup_database_skeleton(args.config.get_libpq_dsn(),
|
database_import.setup_database_skeleton(args.config.get_libpq_dsn(),
|
||||||
rouser=args.config.DATABASE_WEBUSER)
|
rouser=args.config.DATABASE_WEBUSER)
|
||||||
|
|
||||||
|
if not complete_import:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if not args.prepare_database or args.no_superuser or complete_import:
|
||||||
LOG.warning('Setting up country tables')
|
LOG.warning('Setting up country tables')
|
||||||
country_info.setup_country_tables(args.config.get_libpq_dsn(),
|
country_info.setup_country_tables(args.config.get_libpq_dsn(),
|
||||||
args.config.lib_dir.data,
|
args.config.lib_dir.data,
|
||||||
|
|||||||
Reference in New Issue
Block a user