]> git.openstreetmap.org Git - nominatim.git/blob - utils/check_server_for_updates.py
Migration.md - admin also need to run recreate db functions
[nominatim.git] / utils / check_server_for_updates.py
1 #!/usr/bin/env python3
2
3 import sys
4 from osmium.replication import server
5
6 if __name__ == '__main__':
7     if len(sys.argv) != 3:
8         print("Usage: python check_server_for_updates.py <server url> <sequence id>")
9         sys.exit(254)
10
11     seqid = int(sys.argv[2])
12
13     state = server.ReplicationServer(sys.argv[1]).get_state_info()
14
15     if state is None:
16         print("ERROR: Cannot get state from URL %s." % (sys.argv[1], ))
17         sys.exit(253)
18
19     if state.sequence <= seqid:
20         print("Database up to date.")
21         sys.exit(1)
22
23     print("New data available (%i => %i)." % (seqid, state.sequence))
24     sys.exit(0)