]> git.openstreetmap.org Git - nominatim.git/blob - utils/check_server_for_updates.py
Merge pull request #1099 from lonvia/sanity-check-pyosmium
[nominatim.git] / utils / check_server_for_updates.py
1 #!/usr/bin/python
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)