mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
make-indexes on tile_gen
This commit is contained in:
@@ -80,6 +80,8 @@ def http_host_autoupdate(hostname, user, port):
|
|||||||
|
|
||||||
c = get_connection(hostname, user, port)
|
c = get_connection(hostname, user, port)
|
||||||
|
|
||||||
|
c.sudo('rm -f /etc/cron.d/ofm_http_host')
|
||||||
|
|
||||||
prepare_shared(c)
|
prepare_shared(c)
|
||||||
upload_http_host_config(c)
|
upload_http_host_config(c)
|
||||||
|
|
||||||
|
|||||||
@@ -4,17 +4,26 @@ from pathlib import Path
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
from http_host_lib.config import config
|
||||||
from http_host_lib.utils import download_file_aria2, download_if_size_differs
|
from http_host_lib.utils import download_file_aria2, download_if_size_differs
|
||||||
|
|
||||||
|
|
||||||
def download_and_extract_asset_tar_gz(assets_dir, asset_kind):
|
def download_assets():
|
||||||
|
download_and_extract_asset_tar_gz('fonts')
|
||||||
|
download_and_extract_asset_tar_gz('styles')
|
||||||
|
download_and_extract_asset_tar_gz('natural_earth')
|
||||||
|
|
||||||
|
download_sprites()
|
||||||
|
|
||||||
|
|
||||||
|
def download_and_extract_asset_tar_gz(asset_kind):
|
||||||
"""
|
"""
|
||||||
Download and extract asset.tgz if the file size differ or not available locally
|
Download and extract asset.tgz if the file size differ or not available locally
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print(f'Downloading asset {asset_kind}')
|
print(f'Downloading asset {asset_kind}')
|
||||||
|
|
||||||
asset_dir = assets_dir / asset_kind
|
asset_dir = config.assets_dir / asset_kind
|
||||||
asset_dir.mkdir(exist_ok=True, parents=True)
|
asset_dir.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
url = f'https://assets.openfreemap.com/{asset_kind}/ofm.tar.gz'
|
url = f'https://assets.openfreemap.com/{asset_kind}/ofm.tar.gz'
|
||||||
@@ -34,15 +43,15 @@ def download_and_extract_asset_tar_gz(assets_dir, asset_kind):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def download_sprites(assets_dir: Path):
|
def download_sprites():
|
||||||
"""
|
"""
|
||||||
Sprites are special assets, as we have to keep the old versions indefinitely
|
Sprites are special assets, as we have to keep the old versions indefinitely
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sprites_dir = assets_dir / 'sprites'
|
sprites_dir = config.assets_dir / 'sprites'
|
||||||
sprites_dir.mkdir(exist_ok=True, parents=True)
|
sprites_dir.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
r = requests.get('https://assets.openfreemap.com/index.txt', timeout=30)
|
r = requests.get('https://assets.openfreemap.com/files.txt', timeout=30)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
|
||||||
sprites_remote = [l for l in r.text.splitlines() if l.startswith('sprites/')]
|
sprites_remote = [l for l in r.text.splitlines() if l.startswith('sprites/')]
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ from http_host_lib.utils import download_file_aria2, get_remote_file_size
|
|||||||
|
|
||||||
|
|
||||||
def download_area_version(area: str, version: str):
|
def download_area_version(area: str, version: str):
|
||||||
print('running download_btrfs')
|
|
||||||
|
|
||||||
if area not in config.areas:
|
if area not in config.areas:
|
||||||
sys.exit(f' please specify area: {config.areas}')
|
sys.exit(f' please specify area: {config.areas}')
|
||||||
|
|
||||||
@@ -42,7 +40,7 @@ def download_and_extract_btrfs(area: str, version: str) -> bool:
|
|||||||
returns True if download successful, False if skipped
|
returns True if download successful, False if skipped
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print(f'downloading {area} {version}')
|
print(f'downloading and extracting btrfs for: {area} {version}')
|
||||||
|
|
||||||
version_dir = config.runs_dir / area / version
|
version_dir = config.runs_dir / area / version
|
||||||
btrfs_file = version_dir / 'tiles.btrfs'
|
btrfs_file = version_dir / 'tiles.btrfs'
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# debug, once per minute create indexes
|
# once per minute, create indexes
|
||||||
#* * * * * ofm sudo /data/ofm/venv/bin/python -u /data/ofm/tile_gen/bin/tile_gen.py make-indexes >> /data/ofm/tile_gen/logs/debug-cron.log 2>&1
|
* * * * * ofm sudo /data/ofm/venv/bin/python -u /data/ofm/tile_gen/bin/tile_gen.py make-indexes >> /data/ofm/tile_gen/logs/make-indexes-cron.log 2>&1
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def make_indexes():
|
|||||||
Make indexes for all buckets
|
Make indexes for all buckets
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for bucket in ['ofm-btrfs']:
|
for bucket in ['ofm-btrfs', 'ofm-assets']:
|
||||||
make_indexes_for_bucket(bucket)
|
make_indexes_for_bucket(bucket)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user