Nettoyage des restes de paiement par année scolaire
Ça fait plus d'un an qu'on est passés aux factures avec generalizedTimeFormat
This commit is contained in:
parent
af0e971764
commit
baf79bdda7
13 changed files with 498 additions and 220 deletions
|
@ -21,10 +21,10 @@
|
|||
import sys
|
||||
import os, re, syslog, cPickle, socket
|
||||
|
||||
from ldap_crans import crans_ldap, hostname
|
||||
from ldap_crans import crans_ldap, hostname, generalizedTimeFormat
|
||||
from commands import getstatusoutput
|
||||
from config import NETs, role, prefix, rid, output_file, filter_policy, rid_primaires
|
||||
from config import blacklist_sanctions, blacklist_sanctions_soft, blacklist_bridage_upload, file_pickle, ann_scol, periode_transitoire
|
||||
from config import blacklist_sanctions, blacklist_sanctions_soft, blacklist_bridage_upload, file_pickle, periode_transitoire, gtf_debut_periode_transitoire
|
||||
from iptools import AddrInNet
|
||||
from ridtools import Rid, find_rid_plage
|
||||
import subprocess
|
||||
|
@ -257,7 +257,7 @@ REJECT --reject-with icmp6-port-unreachable')
|
|||
os.remove(file_pickle[ip_proto])
|
||||
|
||||
# On sauve les chaînes
|
||||
|
||||
|
||||
save_pickle(ipt_p)
|
||||
return 0
|
||||
|
||||
|
@ -330,16 +330,16 @@ REJECT --reject-with icmp6-port-unreachable')
|
|||
# ipt_p.filter.mac.items.remove[i]
|
||||
# break
|
||||
# print "Erreur, la mac " + mac + " n'est pas dans la chaîne."
|
||||
#
|
||||
#
|
||||
# for mac in macs['add']:
|
||||
# ipt_p.macip(mac)
|
||||
#
|
||||
#
|
||||
# # On écrit et applique les règles
|
||||
# write_rules(ipt_p)
|
||||
# apply_rules(6)
|
||||
#
|
||||
#
|
||||
# os.remove(file_pickle[ip_proto])
|
||||
#
|
||||
#
|
||||
# # On sauve les chaînes
|
||||
# save_pickle(ipt_p)
|
||||
# return 0
|
||||
|
@ -459,18 +459,18 @@ class UnknowUserError(Exception):
|
|||
|
||||
##############################################################################
|
||||
#
|
||||
# Déclaration des fonctions
|
||||
# Déclaration des fonctions
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
def gethostbyname(hostname):
|
||||
hosts4=[]
|
||||
hosts6=[]
|
||||
try :
|
||||
try :
|
||||
for host in socket.getaddrinfo(hostname,None,socket.AF_INET,socket.IPPROTO_IP,socket.AI_CANONNAME):
|
||||
hosts4.append(host[4][0])
|
||||
except(socket.gaierror): pass
|
||||
try :
|
||||
try :
|
||||
for host in socket.getaddrinfo(hostname,None,socket.AF_INET6,socket.IPPROTO_IP,socket.AI_CANONNAME):
|
||||
hosts6.append(host[4][0])
|
||||
except(socket.gaierror): pass
|
||||
|
@ -544,14 +544,14 @@ def iface6(net):
|
|||
|
||||
raise NoIface(net, msg)
|
||||
|
||||
|
||||
|
||||
def check_table(table):
|
||||
''' Vérifie que la table existe bien '''
|
||||
ctables = open('/etc/iproute2/rt_tables', 'r')
|
||||
rt_tables = ctables.readlines()
|
||||
tables = [item for item in rt_tables if not re.match('#', item)]
|
||||
if any(re.search(table, elt) for elt in tables):
|
||||
return 0
|
||||
return 0
|
||||
else:
|
||||
raise NoRtTable(table)
|
||||
|
||||
|
@ -682,7 +682,7 @@ def disable_forwarding(ip_proto = 4):
|
|||
|
||||
|
||||
def not_private(arg):
|
||||
''' Retourne un boolén suivant que la fonction passé en argument
|
||||
''' Retourne un boolén suivant que la fonction passé en argument
|
||||
est privée ou non'''
|
||||
if re.match('^_.*', str(arg)):
|
||||
return False
|
||||
|
@ -727,7 +727,7 @@ def write_rules(ipt):
|
|||
}
|
||||
|
||||
# On parcours une première fois l'instance pour initialiser correctement
|
||||
# nos chaînes
|
||||
# nos chaînes
|
||||
for itables in ['filter', 'mangle', 'raw']:
|
||||
for ichain in filter(not_private,
|
||||
dir(ipt.__getattribute__(itables))):
|
||||
|
@ -768,10 +768,14 @@ def blacklist(ipt):
|
|||
if [x for x in sanctions if x in blacklist_sanctions_ipv6]:
|
||||
blcklst.extend(target.machines())
|
||||
|
||||
s = db.search('mblacklist=*&paiement=%s' % ann_scol)
|
||||
s = db.search('mblacklist=*&finConnexion>=%(fin)s&finAdhesion>=%(fin)s' % {
|
||||
'fin': generalizedTimeFormat(),
|
||||
})
|
||||
if periode_transitoire:
|
||||
s['machine'].extend(db.search('mblacklist=*&paiement=%s' % (ann_scol-1))['machine'])
|
||||
|
||||
s['machine'].extend(db.search('mblacklist=*&finConnexion>=%(fin)s&finAdhsion>=%(fin)s' % {
|
||||
'fin': gtf_debut_periode_transitoire,
|
||||
})['machine'])
|
||||
|
||||
for target in s['machine']:
|
||||
sanctions = target.blacklist_actif()
|
||||
if [x for x in sanctions if x in blacklist_sanctions_ipv6]:
|
||||
|
@ -837,7 +841,7 @@ def macips(ipt, machines, types_machines):
|
|||
if int(machine.rid()) in range(plage[0], plage[1]):
|
||||
ipt.macip(machine.mac(), type_m)
|
||||
break
|
||||
|
||||
|
||||
for type_m in types_machines:
|
||||
if not type_m in tab.keys():
|
||||
type_mm = re.sub('-', '', type_m)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue