Skip to content

Commit

Permalink
Add a verbose switch to generate-worldmap
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed Aug 8, 2024
1 parent 1235453 commit 1ffa9cf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mirrormanager2/utility/generate_worldmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

0 comments on commit 1ffa9cf

Please sign in to comment.