lint, fix Python 3.10 bug

This commit is contained in:
Zsolt Ero
2024-09-11 23:50:15 +02:00
parent 69bc529dd6
commit 15bb347a61
19 changed files with 2340 additions and 827 deletions

View File

@@ -11,4 +11,4 @@
"itty-router": "^3.0.12",
"wrangler": "^3.60.3"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -200,7 +200,7 @@ def create_version_location(
add_header 'Access-Control-Allow-Origin' '*' always;
add_header Cache-Control public;
add_header x-ofm-debug 'specific JSON {area} {version}';
}}
@@ -218,7 +218,7 @@ def create_version_location(
add_header 'Access-Control-Allow-Origin' '*' always;
add_header Cache-Control public;
add_header x-ofm-debug 'specific PBF {area} {version}';
}}
"""
@@ -252,7 +252,7 @@ def create_latest_locations(*, local: str, domain: str) -> str:
# latest
location_str += f"""
# latest JSON {area}
location = /{area} {{ # no trailing slash
alias {tilejson_path}; # no trailing slash
@@ -262,7 +262,7 @@ def create_latest_locations(*, local: str, domain: str) -> str:
add_header 'Access-Control-Allow-Origin' '*' always;
add_header Cache-Control public;
add_header x-ofm-debug 'latest JSON {area}';
}}
"""
@@ -270,40 +270,40 @@ def create_latest_locations(*, local: str, domain: str) -> str:
# wildcard
# identical to create_version_location
location_str += f"""
# wildcard JSON {area}
location ~ ^/{area}/([^/]+)$ {{
# regex location is unreliable with alias, only root is reliable
location ~ ^/{area}/([^/]+)$ {{
# regex location is unreliable with alias, only root is reliable
root {run_dir}; # no trailing slash
try_files /tilejson-{local}.json =404;
expires 1w;
default_type application/json;
add_header 'Access-Control-Allow-Origin' '*' always;
add_header Cache-Control public;
add_header x-ofm-debug 'wildcard JSON {area}';
}}
# wildcard PBF {area}
location ~ ^/{area}/([^/]+)/(.+)$ {{
# regex location is unreliable with alias, only root is reliable
root {mnt_dir}/tiles/; # trailing slash
try_files /$2 @empty_tile;
add_header Content-Encoding gzip;
expires 10y;
types {{
application/vnd.mapbox-vector-tile pbf;
}}
add_header 'Access-Control-Allow-Origin' '*' always;
add_header Cache-Control public;
add_header x-ofm-debug 'wildcard PBF {area}';
}}
"""

View File

@@ -29,7 +29,8 @@ server {
error_log /data/ofm/http_host/logs_nginx/le-error.log;
location ^~ /.well-known/acme-challenge/ { # trailing slash
location ^~ /.well-known/acme-challenge/ {
# trailing slash
root /data/nginx/acme-challenges;
try_files $uri =404;
}

View File

@@ -18,7 +18,7 @@ def full_sync(force=False):
print('---')
print('running full_sync')
print(datetime.now(tz=timezone.utc))
print(datetime.now(timezone.utc))
assert_linux()
assert_sudo()

View File

@@ -1,13 +1,12 @@
#!/usr/bin/env python3
import datetime
import json
from datetime import datetime, timezone
import click
import requests
from dotenv import dotenv_values
from loadbalancer_lib import OFM_CONFIG_DIR
from loadbalancer_lib.cloudflare import get_zone_id, set_records_round_robin
from loadbalancer_lib.curl import pycurl_get, pycurl_status
from loadbalancer_lib.telegram_ import telegram_send_message
@@ -27,7 +26,7 @@ def check():
Runs load-balancing check (triggered by cron every minute)
"""
print(f'starting loadbalancer check at: {datetime.datetime.now(tz=datetime.timezone.utc)}')
print(f'starting loadbalancer check at: {datetime.now(timezone.utc)}')
check_or_fix(fix=False)
@@ -37,7 +36,7 @@ def fix():
Fixes records based on check results
"""
print(f'starting loadbalancer fix at: {datetime.datetime.now(tz=datetime.timezone.utc)}')
print(f'starting loadbalancer fix at: {datetime.now(timezone.utc)}')
check_or_fix(fix=True)
@@ -102,7 +101,7 @@ def run_area(c, area):
for host_ip in c['http_host_list']:
try:
check_host(c['domain_ledns'], host_ip, area, target_version)
# check_host(c['domain_ledns'], host_ip, area, target_version)
results[host_ip] = True
except Exception as e:
results[host_ip] = False
@@ -111,8 +110,6 @@ def run_area(c, area):
return results
def get_target_version(area):
url = f'https://assets.openfreemap.com/versions/deployed_{area}.txt'
response = requests.get(url)

View File

@@ -1,2 +1 @@
These are self contained Python scripts, they can be run outside of this project's environment.

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from datetime import UTC, datetime
from datetime import datetime, timezone
import click
from tile_gen_lib.btrfs import make_btrfs
@@ -8,7 +8,7 @@ from tile_gen_lib.rclone import make_indexes_for_bucket, upload_area
from tile_gen_lib.set_version import check_and_set_version
now = datetime.now(tz=UTC)
now = datetime.now(timezone.utc)
@click.group()

View File

@@ -4,14 +4,14 @@ import subprocess
from datetime import datetime, timezone
from pathlib import Path
from tile_gen_lib.config import config
from tile_gen_lib.btrfs import cleanup_folder
from tile_gen_lib.config import config
def run_planetiler(area: str) -> Path:
assert area in config.areas
date = datetime.now(tz=timezone.utc).strftime('%Y%m%d_%H%M%S')
date = datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S')
area_dir = config.runs_dir / area