def test_run_legacy_default_osm2pgsql_binary(self, monkeypatch): fname = self.mk_script( "exit($_SERVER['NOMINATIM_OSM2PGSQL_BINARY'] == 'osm2pgsql' ? 0 : 23);" ) assert exec_utils.run_legacy_script(fname, nominatim_env=self.testenv) == 0
def test_run_legacy_do_not_overwrite_module_path(nominatim_env, test_script, monkeypatch): monkeypatch.setenv('NOMINATIM_DATABASE_MODULE_PATH', 'other') fname = test_script( "exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == 'other' ? 0 : 1);") assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env)
def _warm(args): LOG.warning('Warming database caches') params = ['warm.php'] if args.target == 'reverse': params.append('--reverse-only') if args.target == 'search': params.append('--search-only') return run_legacy_script(*params, nominatim_env=args)
def test_run_legacy_override_osm2pgsql_binary(self, monkeypatch): monkeypatch.setenv('NOMINATIM_OSM2PGSQL_BINARY', 'somethingelse') fname = self.mk_script( "exit($_SERVER['NOMINATIM_OSM2PGSQL_BINARY'] == 'somethingelse' ? 0 : 23);" ) assert exec_utils.run_legacy_script(fname, nominatim_env=self.testenv) == 0
def run(args): if args.tiger_data: return tiger_data.add_tiger_data(args.tiger_data, args.config, args.threads or 1) params = ['update.php'] if args.file: params.extend(('--import-file', args.file)) elif args.diff: params.extend(('--import-diff', args.diff)) elif args.node: params.extend(('--import-node', args.node)) elif args.way: params.extend(('--import-way', args.way)) elif args.relation: params.extend(('--import-relation', args.relation)) if args.use_main_api: params.append('--use-main-api') return run_legacy_script(*params, nominatim_env=args)
def run(args): params = [ 'export.php', '--output-type', args.output_type, '--output-format', args.output_format ] if args.output_all_postcodes: params.append('--output-all-postcodes') if args.language: params.extend(('--language', args.language)) if args.restrict_to_country: params.extend(('--restrict-to-country', args.restrict_to_country)) if args.restrict_to_osm_node: params.extend( ('--restrict-to-osm-node', args.restrict_to_osm_node)) if args.restrict_to_osm_way: params.extend(('--restrict-to-osm-way', args.restrict_to_osm_way)) if args.restrict_to_osm_relation: params.extend( ('--restrict-to-osm-relation', args.restrict_to_osm_relation)) return run_legacy_script(*params, nominatim_env=args)
def test_run_legacy_use_given_module_path(nominatim_env, test_script): fname = test_script( "exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == '' ? 0 : 23);") assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env)
def test_run_legacy_return_dont_throw_on_success(nominatim_env, test_script): fname = test_script('exit(0);') assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env, throw_on_fail=True)
def test_run_legacy_return_throw_on_fail(nominatim_env, test_script): fname = test_script('exit(11);') with pytest.raises(subprocess.CalledProcessError): exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env, throw_on_fail=True)
def test_run_legacy_return_exit_code(nominatim_env, test_script, return_code): fname = test_script('exit({});'.format(return_code)) assert return_code == exec_utils.run_legacy_script( fname, nominatim_env=nominatim_env)
def test_run_legacy_use_given_module_path(self): fname = self.mk_script( "exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == '' ? 0 : 23);") assert exec_utils.run_legacy_script(fname, nominatim_env=self.testenv) == 0
def test_run_legacy_return_dont_throw_on_success(self): fname = self.mk_script('exit(0);') assert exec_utils.run_legacy_script(fname, nominatim_env=self.testenv, throw_on_fail=True) == 0
def test_run_legacy_return_exit_code(self, return_code): fname = self.mk_script('exit({});'.format(return_code)) assert return_code == \ exec_utils.run_legacy_script(fname, nominatim_env=self.testenv)