[annuaire] On passe sur ula base de données PgSQL

darcs-hash:20100831065041-ffbb2-c44e28237d99ba472e0465ad88f1cd7149e3081d.gz
This commit is contained in:
Nicolas Dandrimont 2010-08-31 08:50:41 +02:00
parent 337905013d
commit a1427076b5
15 changed files with 32 additions and 35 deletions

View file

@ -32,6 +32,8 @@ import sys, os
sys.path.append('/usr/scripts/gestion')
raise EnvironmentError("Ce script est *vieux*")
from annuaires import chbre_prises, reverse, bat_switchs
from affich_tools import cprint
@ -60,7 +62,7 @@ prise doit être de la forme bnnn[g/d], ou nnn[g/d], dans ce dernier cas le bât
prise = prise[1:]
if chbre_prises[bat].get(chbre):
if chbre_prises(bat).get(chbre):
return 'chambre_deja_cablee'
# dico = reverse(bat)

View file

@ -19,14 +19,12 @@ import sys, os, commands, smtplib, tempfile, getopt
sys.path.append('/usr/scripts/gestion')
from hptools import hpswitch, sw_chbre
from ldap_crans import crans_ldap, BorneWifi
from annuaires import chbre_prises, uplink_prises, reverse, bat_manuels, all_switchs
from annuaires_pg import uplink_prises, reverse, bat_manuels, all_switchs, bat_switchs
from random import shuffle
from gen_confs import *
from time import localtime
import config
from annuaires import bat_switchs
try:
any
except NameError:

View file

@ -13,7 +13,7 @@ from time import sleep
from popen2 import popen3
from sys import stderr, path
from commands import getstatusoutput
from annuaires import chbre_prises, all_switchs
from annuaires_pg import chbre_prises, all_switchs
from os.path import exists
from os import system
import sys
@ -415,7 +415,7 @@ class sw_chbre(hpswitch) :
self.chbre = chbre
try :
bat = chbre[0].lower()
prise = chbre_prises[bat][chbre[1:]]
prise = chbre_prises(bat, chbre[1:])
self.prise_brute = prise
self.switch = 'bat%s-%i.adm.crans.org' % (bat , int(prise[0]) )
if prise[-1] == '-' :

View file

@ -13,7 +13,8 @@ from socket import gethostname
import smtplib, re, os, random, string, time, sys, pwd
import ldap, ldap.modlist, ldap_passwd
import config, annuaires, iptools, cPickle, config_mail
import annuaires_pg as annuaires
import config, iptools, cPickle, config_mail
from chgpass import chgpass
from affich_tools import coul, prompt, cprint
from email_tools import send_email
@ -875,7 +876,7 @@ class CransLdap:
"""
Renvoie un proprietaire ou un adherent correspondant au
login/ mot de passe (mot de passe facultatif)
"""
"""
recherche = self.search(("uid=%s" % uid), mode)
proprio = None
@ -1949,9 +1950,9 @@ class Adherent(BaseProprietaire):
new = new.capitalize()
bat = new[0].lower()
if bat in annuaires.chbre_prises.keys():
if bat in annuaires.bat_switchs:
# On a la liste des chambres
chbres = annuaires.chbre_prises[bat].keys()
chbres = annuaires.chbre_prises(bat).keys()
if new[1:] not in chbres or len(new)<4 or not new[1:4].isdigit():
chbres.sort()
aide = u"Chambre inconnue dans le batiment, les chambres valides sont :"
@ -1965,7 +1966,6 @@ class Adherent(BaseProprietaire):
aide += c.ljust(5)
a = a+1
aide += u'\n'
aide += u" " + annuaires.aide.get(bat, '')
raise ValueError(aide)
else:
@ -2781,9 +2781,9 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3)
return decode(self._data.get('prise', ['N/A'])[0])
else:
chbre = self.proprietaire().chbre()
if chbre and chbre[0].lower() in annuaires.chbre_prises.keys():
if chbre and chbre[0].lower() in annuaires.bat_switchs:
try:
return annuaires.chbre_prises[chbre[0].lower()][chbre[1:]]
return annuaires.chbre_prises(chbre[0], chbre[1:])
except:
return 'N/A'

View file

@ -8,7 +8,7 @@ J.Benoist Leger
"""
from time import sleep
from annuaires import all_switchs
from annuaires_pg import all_switchs
import pexpect
import getopt
import sys

View file

@ -9,7 +9,7 @@ import threading
sys.path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap
import whos
from annuaires import reverse, all_switchs
from annuaires_pg import all_switchs
from hptools import hpswitch
# mise en forme d'une adresse mac

View file

@ -1152,13 +1152,10 @@ def __recherche() :
prise = arg.split('=')[1]
# Récupération de la chambre
try:
from annuaires import reverse
chbre = reverse(prise[0].lower())[prise[1:]]
from annuaires_pg import reverse
chbre = reverse(prise[0].lower(), prise[1:])
except KeyError:
try:
chbre = reverse(prise[0].lower())[prise[1:]+'-']
except KeyError:
chbre=None
chbre=None
if chbre:
if len(chbre) != 1 :