From e93c17042405a1e5ca38a0fcf8aef042701a64fa Mon Sep 17 00:00:00 2001 From: Dominik Heidler Date: Fri, 27 Nov 2015 15:54:47 +0100 Subject: [PATCH] update find_bad_mesh script --- contrib/find_bad_mesh.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/find_bad_mesh.py b/contrib/find_bad_mesh.py index 95a741b..4660a85 100755 --- a/contrib/find_bad_mesh.py +++ b/contrib/find_bad_mesh.py @@ -1,13 +1,13 @@ -#!/usr/bin/python +#!/usr/bin/python3 from pymongo import MongoClient client = MongoClient() db = client.freifunk -for router in db.routers.find({"hood": {"$exists": True}, "neighbours": {"$exists": True}}): +for router in db.routers.find({"hood": {"$exists": True}, "neighbours": {"$exists": True}, "status": "online"}, {"stats": 0}): for neighbour in router["neighbours"]: if "_id" in neighbour and "position" in neighbour: - neighbour_router = db.routers.find_one({"_id": neighbour["_id"]}) - if router["hood"] != neighbour_router["hood"]: + neighbour_router = db.routers.find_one({"_id": neighbour["_id"]}, {"stats": 0}) + if router["hood"] != neighbour_router["hood"] and neighbour_router["status"] == "online": print("Illegal inter-hood-mesh between %s (%s) and %s (%s)!" % (router["hostname"], router["hood"], neighbour_router["hostname"], neighbour_router["hood"]))