Update recache script description

This commit is contained in:
Maciej Ziarkowski 2020-06-25 05:03:24 +01:00
parent 24a0861589
commit 1755f6344a

View File

@ -7,6 +7,7 @@
"""
import argparse
import os
from pathlib import Path
import re
import sys
@ -21,7 +22,7 @@ def clear_cache(cache_dir: Path, tile: str):
print(f"Warning: cached tile {tile} did not exist", file=sys.stderr)
def recreate_tile(hostname: str, port: int, tile: str):
tile_url = f'{hostname}/tiles/{tile}'
tile_url = f'{hostname}:{port}/tiles/{tile}'
req = requests.get(tile_url)
if req.status_code != 200:
raise Exception(f"Tile request for tile {tile} returned status {req.status_code} (data: {req.json()})")
@ -44,7 +45,7 @@ def main(cache_dir: Path, tile_list: Path, hostname: str, port: int):
if __name__=='__main__':
parser = argparse.ArgumentParser(
parser = argparse.ArgumentParser(description=
'''
Re-cache map tiles listed in a file.
@ -57,11 +58,11 @@ if __name__=='__main__':
The order of lines in the file determines the order of re-caching.
Names of re-cached tiles are printed to standard output.
''')
''', formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('cache_directory', type=Path, help='The root directory of the tile cache (needs to be local)')
parser.add_argument('tile_list', type=Path, help='Path to the list of tiles that should be re-cached.')
parser.add_argument('--hostname', type=str, default="127.0.0.1", help='The hostname of the tile server')
parser.add_argument('--hostname', type=str, default="http://127.0.0.1", help='The hostname of the tile server')
parser.add_argument('--port', type=int, default=3000, help='The port numbre of the tile server')
args = parser.parse_args()