mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
uploading and indexes
This commit is contained in:
17
scripts/set_version/setup.py
Normal file
17
scripts/set_version/setup.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
|
||||
requirements = [
|
||||
'click',
|
||||
'requests',
|
||||
'pycurl',
|
||||
'python-dotenv',
|
||||
'questionary',
|
||||
]
|
||||
|
||||
|
||||
setup(
|
||||
python_requires='>=3.10',
|
||||
install_requires=requirements,
|
||||
packages=find_packages(),
|
||||
)
|
||||
62
scripts/set_version/setversion.py
Executable file
62
scripts/set_version/setversion.py
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
|
||||
import click
|
||||
import questionary
|
||||
from setversion_lib import RCLONE_BIN, RCLONE_CONF
|
||||
|
||||
|
||||
@click.group()
|
||||
def cli():
|
||||
"""
|
||||
Sets deployed reference versions
|
||||
"""
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.argument('area', required=True)
|
||||
def interactive(area):
|
||||
versions = get_available_versions(area)[::-1]
|
||||
|
||||
choices = [questionary.Choice(title=r, value=i) for i, r in enumerate(versions)]
|
||||
answer = questionary.select(f'Select version for: {area}', choices=choices).ask()
|
||||
|
||||
selected = versions[answer]
|
||||
|
||||
set_version(area, selected)
|
||||
|
||||
|
||||
def get_available_versions(area):
|
||||
p = subprocess.run(
|
||||
[
|
||||
RCLONE_BIN,
|
||||
'cat',
|
||||
f'remote:ofm-{area}/dirs.txt',
|
||||
],
|
||||
env=dict(RCLONE_CONFIG=RCLONE_CONF),
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
versions = [l.strip() for l in p.stdout.strip().splitlines()]
|
||||
versions.sort()
|
||||
|
||||
return versions
|
||||
|
||||
|
||||
def set_version(area, version):
|
||||
subprocess.run(
|
||||
[
|
||||
RCLONE_BIN,
|
||||
'rcat',
|
||||
f'remote:ofm-assets/versions/deployed_{area}.txt',
|
||||
],
|
||||
env=dict(RCLONE_CONFIG=RCLONE_CONF),
|
||||
check=True,
|
||||
input=version.encode(),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli()
|
||||
16
scripts/set_version/setversion_lib/__init__.py
Normal file
16
scripts/set_version/setversion_lib/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
if Path('/data/ofm/config').exists():
|
||||
OFM_CONFIG_DIR = Path('/data/ofm/config')
|
||||
else:
|
||||
OFM_CONFIG_DIR = Path(__file__).parent.parent.parent.parent / 'config'
|
||||
|
||||
assert OFM_CONFIG_DIR.exists()
|
||||
|
||||
RCLONE_CONF = OFM_CONFIG_DIR / 'rclone.conf'
|
||||
|
||||
if Path('/opt/homebrew/bin/rclone').exists():
|
||||
RCLONE_BIN = '/opt/homebrew/bin/rclone'
|
||||
else:
|
||||
RCLONE_BIN = 'rclone'
|
||||
Reference in New Issue
Block a user