From 1ffa9cf8c0012412c1cbf565cc88bf5e370609b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bompard?= Date: Thu, 8 Aug 2024 08:25:58 +0200 Subject: [PATCH] Add a verbose switch to generate-worldmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Bompard --- mirrormanager2/utility/generate_worldmap.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mirrormanager2/utility/generate_worldmap.py b/mirrormanager2/utility/generate_worldmap.py index ba5fb4ef..94aecbb0 100755 --- a/mirrormanager2/utility/generate_worldmap.py +++ b/mirrormanager2/utility/generate_worldmap.py @@ -22,7 +22,8 @@ @click.command() @config_option -def main(config): +@click.option("--verbose", is_flag=True, default=False, help="show more details") +def main(config, verbose): config = mirrormanager2.lib.read_config(config) gi = geoip2.database.Reader(os.path.join(config["GEOIP_BASE"], "GeoLite2-City.mmdb")) db_manager = get_db_manager(config) @@ -44,12 +45,15 @@ def main(config): if gir is None: continue if gir.country.iso_code in embargoed_countries: - print( + click.echo( f"WARNING: host {host.id} ({hostname}) seems to be from an embargoed " - f"country: {gir.country.iso_code}" + f"country: {gir.country.iso_code}", + err=True, ) continue host.latitude = gir.location.latitude host.longitude = gir.location.longitude tracking.add(host.id) + if verbose: + click.echo(f"{host.name} ({host.id}): {host.latitude} {host.longitude}") session.commit()