-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (25 loc) · 916 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/python
import input
import process
import output
import sys
# Parameter:
# nichts: Nur Status
# --mail: Schicke Mail
# Lese Daten ein
# A) Nodes, die beobachtet werden (nodelist.json)
# B) Alle Nodes (data)
if "nomail" in sys.argv:
nomail=True
print("Simuliere... sende keine Mail")
# Input: Die beiden JSON
data = input.get_json_from_url('https://map.freifunk-myk.de/hopglass/nodes.json')
nodelist_json = input.get_json_from_local('nodelist.json')
# Extrahiere lastseen und hostname und führe zusammen
lastseen_list, hostname_list = process.extract_hostname_and_lastseen(data["nodes"])
nodelist_json = process.merge_data(nodelist_json, hostname_list, lastseen_list)
# TODO: Sortieren nach Timedelta
# Output auf Konsole und bei Bedarf Mail
output.worker_stdout(nodelist_json["nodes"])
process.test_sites(data["nodes"])
output.worker_mail(nodelist_json["nodes"], nodelist_json["keeper"],nomail)