[mac_prises] Enough tested.

This commit is contained in:
Pierre-Elliott Bécue 2014-10-11 00:45:19 +02:00
parent ddc6fb8a98
commit ecc25c09b1

View file

@ -3,7 +3,7 @@
#
# Sclaimer
# PEB : 01/02/2013 -> now()
#
#
# Blablabla. (cf mac_prise.py)
import psycopg2
@ -60,7 +60,7 @@ def genere_comptage(duree):
"""
Grosse fonction de hack pour ne pas écrire six fois le même formatage de sortie bidon.
Prend en argument :
* duree, qui peut valoir 'instant', 'heuristique', ou 'journalier', permet d'importer
les variables de config qui vont bien
"""
@ -93,7 +93,7 @@ def genere_comptage(duree):
Logs.append(u"Entrée rejetée du tableau %s, car rapport inférieur au seuil : (%s).\n\n" % (duree, rapport))
else:
pass
if len(pb_comptage_suspect) > 0:
for clef, valeur in pb_comptage_suspect.items():
requete = "INSERT INTO spotted (mac, type, chambre, date, rapport, seuil) VALUES(%s, %s, %s, %s, %s, %s);"
@ -191,13 +191,13 @@ def reperage_mac_inconnue():
longueur_max = max([len(", ".join(a[0])) for a in probleme.values()] + [len("macs")]) + 2
largeurs = (len('chambre') + 2, longueur_max, len('compteur') + 2, len('seuil') + 2)
data = []
clefs = probleme.keys()
clefs.sort()
for clef in clefs:
data.append([clef, ", ".join(probleme[clef][0]), probleme[clef][1], mac_prise.max_inconnues_par_jour])
output += tableau(data, ('chambre', 'macs', 'compteur', 'seuil'), largeurs, ('c', 'c', 'c', 'c'))
output += u"\n\n\n"
@ -242,7 +242,7 @@ Content-Disposition: attachment; filename="logs_analyse"
--_424234545aaff-ffca234efff-556adceff5646_--
"""
corps = message % { 'from': 'Spoofing watcher <spoof-watcher@crans.org>',
'to': 'test@lists.crans.org',
'subject': 'Résumé journalier ',
@ -260,7 +260,7 @@ Content-Disposition: attachment; filename="logs_analyse"
genere_comptage('moyen')
genere_comptage('journalier')
if time.localtime().tm_min % 30 == 0 and mac_prise.hargneux:
if mac_prise.hargneux:
hargneux = True
else:
hargneux = False
@ -273,7 +273,7 @@ Content-Type: text/plain; charset="UTF-8"
%(logs)s
"""
corps = message % { 'from': 'Spoofing watcher <spoof-watcher@crans.org>',
'to': 'test@lists.crans.org',
'subject': 'Logs de %s' % sys.argv[0],