Skip to content

Commit 8b7d01a

Browse files
authored
Merge pull request #2466 from lonvia/optional-replication-in-test
Fix presence check for replication script in style tester
2 parents 8b9f223 + d673401 commit 8b7d01a

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

scripts/osm2pgsql-test-style

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,18 @@ class ReplicationServerMock:
9494
return min(self.state_infos[-1].sequence, start_id + numdiffs - 1)
9595

9696
# Replication module is optional
97-
_repfl_spec = importlib.util.spec_from_loader(
98-
'osm2pgsql_replication',
99-
SourceFileLoader('osm2pgsql_replication',
100-
str(Path(__file__, '..', 'osm2pgsql-replication').resolve())))
97+
_replication_path = Path(__file__, '..', 'osm2pgsql-replication').resolve()
98+
99+
if _replication_path.is_file():
100+
_repfl_spec = importlib.util.spec_from_loader(
101+
'osm2pgsql_replication',
102+
SourceFileLoader('osm2pgsql_replication', str(_replication_path)))
101103

102-
if _repfl_spec:
103104
osm2pgsql_replication = importlib.util.module_from_spec(_repfl_spec)
104-
_repfl_spec.loader.exec_module(osm2pgsql_replication)
105+
try:
106+
_repfl_spec.loader.exec_module(osm2pgsql_replication)
107+
except Exception as e:
108+
raise RuntimeError(f"osm2pgsql_replication script found but not readable.")
105109

106110
from osmium.replication.server import OsmosisState
107111
else:

0 commit comments

Comments
 (0)