scripts/adm/analyse-batg.py
Antoine Durand-Gasselin 4a68475e34 [wiki-lenny] suppression de static/
darcs-hash:20090314092631-bd074-b01256aeaf71e935851b3ecdbd623eaae8c9e8a1.gz
2009-03-14 10:26:31 +01:00

38 lines
820 B
Python

#! /usr/bin/env python
# -*- coding: iso8859-15 -*-
"""
Ce script sert à donner l'occupation des switchs du batiment G
Il affiche 3 colonnes :
- la prise
- la chambre
- si il y a qqun dans la chambre
"""
import sys
sys.path.append('/usr/scripts/gestion')
from annuaires import reverse
from ldap_crans import crans_ldap
from affich_tools import tableau
db = crans_ldap()
# dictionnaire revers du bat
dico = reverse('g')
# toutes les prises
prises = dico.keys()
prises.sort()
# chambres occupées
chbres = [ a.chbre() for a in db.search('chbre=G*&paiement=ok')['adherent'] ]
data= []
for p in prises:
if [ chbre for chbre in dico[p] if 'G%s'%chbre in chbres ]:
data.append( [ p, ','.join(dico[p]), 'O'] )
else:
data.append( [ p, ','.join(dico[p]), 'N'] )
print tableau(data)