erster commit
This commit is contained in:
commit
669c9ff352
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
.DS_Store
|
||||
fastdkeys
|
||||
fastdkeys/*
|
||||
ausserhalb/Nachricht.txt
|
||||
ausserhalb/ausserhalb_hh.txt
|
||||
!.gitignore
|
102
ausserhalb/a.py
Executable file
102
ausserhalb/a.py
Executable file
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import time
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
Pfad_Formulardaten = '/home/fastdform/fastdkeys/'
|
||||
Knotenliste = "./ausserhalb_hh.txt"
|
||||
Nachrichtdateiname = "./Nachricht.txt"
|
||||
Betreff = "Wechsel zu ffnord, Pinneberg, Stormarn & Lauenburg"
|
||||
Absender = 'kontakt@hamburg.freifunk.net'
|
||||
Hat_schon_eine_Nachricht_bekommen = []
|
||||
|
||||
#Inhalt der Nachricht lesen
|
||||
Nachrichtdatei = open(Nachrichtdateiname)
|
||||
Nachricht = Nachrichtdatei.read()
|
||||
Nachrichtdatei.close()
|
||||
|
||||
Adresse = ''
|
||||
Ansprechpartner = ''
|
||||
Knotenname = ''
|
||||
Token = ''
|
||||
Koordinaten = ''
|
||||
|
||||
|
||||
def Knotendaten_lesen(Dateiname):
|
||||
#Variblen zuruecksetzen
|
||||
global Adresse
|
||||
Adresse = ''
|
||||
global Ansprechpartner
|
||||
Ansprechpartner = ''
|
||||
global Knotenname
|
||||
Knotenname = ''
|
||||
global Token
|
||||
Token = ''
|
||||
|
||||
Koordinaten = ''
|
||||
|
||||
with open(Dateiname) as Datei:
|
||||
|
||||
#Datei Zeilweise einlesen
|
||||
Zeilen = Datei.readlines()
|
||||
|
||||
for Zeile in Zeilen:
|
||||
|
||||
#Zeile in Wortliste aufspalten
|
||||
Wortliste = Zeile.split()
|
||||
|
||||
if len(Wortliste) > 0:
|
||||
if Wortliste[1] == 'Kontakt:':
|
||||
Adresse = Wortliste[2]
|
||||
elif Wortliste[1] == 'Knotenname:':
|
||||
Knotenname = Wortliste[2]
|
||||
elif Wortliste[1] == 'Ansprechpartner:':
|
||||
Ansprechpartner = Wortliste[2:]
|
||||
elif Wortliste[1] == 'Token:':
|
||||
Token = Wortliste[2]
|
||||
elif Wortliste[1] == 'Koordinaten:':
|
||||
Koordinaten = Wortliste[2:]
|
||||
Datei.close()
|
||||
|
||||
|
||||
with open(Knotenliste) as Datei:
|
||||
|
||||
#Datei Zeilweise einlesen
|
||||
Zeilen = Datei.readlines()
|
||||
for Zeile in Zeilen:
|
||||
|
||||
#Den Zeilenumbruch '\n' abschneiden
|
||||
Zeile=Zeile[0:len(Zeile)-1]
|
||||
|
||||
for Datei in os.listdir(Pfad_Formulardaten):
|
||||
if Datei.startswith(Zeile.lower() + '@'):
|
||||
Knotendaten_lesen(Pfad_Formulardaten + Datei)
|
||||
Adresse = Adresse.lower()
|
||||
|
||||
#falsche Adressen aussortieren
|
||||
if Adresse == "<falsche_adresse>":
|
||||
print("Falsche Adresse für Knoten: "+Knotenname)
|
||||
|
||||
#Nur schicken, falls Adressat noch nichts bekommen hat
|
||||
elif Adresse not in Hat_schon_eine_Nachricht_bekommen:
|
||||
|
||||
#In die Liste der bisherigen Adressaten aufnehmen
|
||||
Hat_schon_eine_Nachricht_bekommen.append(Adresse)
|
||||
|
||||
#email zusammenbauen
|
||||
email = MIMEText(Nachricht, 'plain', 'UTF-8')
|
||||
email['Subject'] = Betreff
|
||||
email['From'] = Absender
|
||||
#email['To'] = Adresse
|
||||
email['To'] = 'andre@hamburg.freifunk.net'
|
||||
|
||||
#mail server Nachricht verschicken lassen
|
||||
s = smtplib.SMTP('localhost')
|
||||
s.sendmail(Absender, email['To'], email.as_string())
|
||||
s.quit()
|
||||
|
||||
#Adressat der letzten versendeten Nachricht ausgeben und 1s warten, um nicht auf spam-Listen zu landen
|
||||
print(Adresse)
|
||||
time.sleep(1)
|
48
ausserhalb/get_nodes_outside_community.py
Executable file
48
ausserhalb/get_nodes_outside_community.py
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env python2
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
import shapely.geometry as s
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print('usage: ' + sys.argv[0] + ' /path/to/config.json /path/to/peers')
|
||||
sys.exit(1)
|
||||
|
||||
configFile = sys.argv[1]
|
||||
peersDir = sys.argv[2]
|
||||
|
||||
config = json.loads(open(configFile).read())
|
||||
|
||||
gpsPoly = config['client']['otherCommunityInfo']['localCommunityPolygon']
|
||||
poly = s.Polygon(map(lambda point: (point['lng'], point['lat']), gpsPoly))
|
||||
|
||||
for filename in os.listdir(peersDir):
|
||||
if len(filename) == 0 or filename[0] == '.':
|
||||
continue
|
||||
|
||||
absFilename = peersDir + '/' + filename
|
||||
if os.path.isfile(absFilename):
|
||||
peerFile = open(absFilename, 'r')
|
||||
try:
|
||||
peerLines = peerFile.readlines()
|
||||
peer = {}
|
||||
mac = None
|
||||
for line in peerLines:
|
||||
parts = line.split()
|
||||
|
||||
if len(parts) > 0:
|
||||
if parts[1] == 'Knotenname:':
|
||||
peer['name'] = parts[2].lower()
|
||||
elif parts[1] == 'Koordinaten:' and len(parts) == 4:
|
||||
peer['gps'] = s.Point((float(parts[3]), float(parts[2])))
|
||||
|
||||
if 'gps' in peer and not peer['gps'].within(poly):
|
||||
print peer['name']
|
||||
|
||||
except Exception as e:
|
||||
print('Error in %s, ignoring peer: %s' % (absFilename, e));
|
||||
finally:
|
||||
peerFile.close()
|
||||
|
Loading…
Reference in a new issue