api: Add wifianalall (all hoods)

Puts reused code into a helper function

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2017-11-10 00:00:42 +01:00
parent 87093a9066
commit 412203a946
1 changed files with 17 additions and 1 deletions

18
ffmap/web/api.py Normal file → Executable file
View File

@ -153,10 +153,26 @@ def wifianal(selecthood):
""",(selecthood,))
mysql.close()
return wifianalhelper(router_data,"Hood: " + selecthood)
@api.route('/wifianalall')
def wifianalall():
mysql = FreifunkMySQL()
router_data = mysql.fetchall("""
SELECT hostname, mac, netif
FROM router
INNER JOIN router_netif ON router.id = router_netif.router
GROUP BY id, netif
""",())
mysql.close()
return wifianalhelper(router_data,"ALL hoods")
def wifianalhelper(router_data, headline):
s = "#----------WifiAnalyzer alias file----------\n"
s += "# \n"
s += "#Freifunk Franken\n"
s += "#Hood: " + selecthood + "\n"
s += "#" + headline + "\n"
s += "# \n"
s += "#Encoding: UTF-8.\n"
s += "#The line starts with # is comment.\n"