mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 22:12:15 +00:00
config refactor
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import datetime
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -6,7 +7,7 @@ from pathlib import Path
|
||||
|
||||
import click
|
||||
import requests
|
||||
from http_host_lib import DEFAULT_ASSETS_DIR, DEFAULT_RUNS_DIR, HOST_CONFIG, MNT_DIR
|
||||
from http_host_lib.config import config
|
||||
from http_host_lib.download_assets import (
|
||||
download_and_extract_asset_tar_gz,
|
||||
download_sprites,
|
||||
@@ -69,7 +70,7 @@ def download_tileset(area: str, version: str, list_versions: bool, runs_dir: Pat
|
||||
selected_version = version
|
||||
|
||||
if not runs_dir:
|
||||
runs_dir = DEFAULT_RUNS_DIR
|
||||
runs_dir = config.default_runs_dir
|
||||
|
||||
if not runs_dir.parent.exists():
|
||||
sys.exit("runs dir's parent doesn't exist")
|
||||
@@ -91,7 +92,7 @@ def download_assets(assets_dir: Path):
|
||||
print('running download_assets')
|
||||
|
||||
if not assets_dir:
|
||||
assets_dir = DEFAULT_ASSETS_DIR
|
||||
assets_dir = config.default_assets_dir
|
||||
|
||||
if not assets_dir.parent.exists():
|
||||
sys.exit("asset dir's parent doesn't exist")
|
||||
@@ -115,16 +116,16 @@ def mount():
|
||||
assert_linux()
|
||||
assert_sudo()
|
||||
|
||||
if not DEFAULT_RUNS_DIR.exists():
|
||||
if not config.default_runs_dir.exists():
|
||||
sys.exit(' download_tileset needs to be run first')
|
||||
|
||||
clean_up_mounts(MNT_DIR)
|
||||
clean_up_mounts(config.mnt_dir)
|
||||
create_fstab()
|
||||
|
||||
print(' running mount -a')
|
||||
subprocess.run(['mount', '-a'], check=True)
|
||||
|
||||
clean_up_mounts(MNT_DIR)
|
||||
clean_up_mounts(config.mnt_dir)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@@ -142,7 +143,7 @@ def set_latest_versions():
|
||||
assert_linux()
|
||||
assert_sudo()
|
||||
|
||||
if not MNT_DIR.exists():
|
||||
if not config.mnt_dir.exists():
|
||||
sys.exit(' mount needs to be run first')
|
||||
|
||||
return set_tileset_versions()
|
||||
@@ -159,7 +160,7 @@ def nginx_sync():
|
||||
assert_linux()
|
||||
assert_sudo()
|
||||
|
||||
if not MNT_DIR.exists():
|
||||
if not config.mnt_dir.exists():
|
||||
sys.exit(' mount needs to be run first')
|
||||
|
||||
write_nginx_config()
|
||||
@@ -184,7 +185,7 @@ def sync(ctx, force):
|
||||
download_done = False
|
||||
download_done += ctx.invoke(download_tileset, area='monaco')
|
||||
|
||||
if not HOST_CONFIG.get('skip_planet'):
|
||||
if not config.host_config.get('skip_planet'):
|
||||
download_done += ctx.invoke(download_tileset, area='planet')
|
||||
|
||||
if download_done:
|
||||
@@ -199,5 +200,5 @@ def sync(ctx, force):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# print(HOST_CONFIG)
|
||||
# print(config.host_config)
|
||||
cli()
|
||||
|
||||
Reference in New Issue
Block a user