Recherche sur prise et amlioration de la recherche sur chambre.
darcs-hash:20041003174054-41617-081936d7fe2b2bab8b667e289c213d5aeade57c0.gz
This commit is contained in:
parent
5f9231525a
commit
0c0014e160
2 changed files with 39 additions and 15 deletions
|
@ -402,6 +402,7 @@ class sw_chbre(hpswitch) :
|
|||
try :
|
||||
bat = chbre[0].lower()
|
||||
prise = chbre_prises[bat][chbre[1:]]
|
||||
self.prise_brute = prise
|
||||
self.switch = 'bat%s' % bat
|
||||
num_switch = int(prise[0])
|
||||
if num_switch != 0 :
|
||||
|
|
|
@ -33,7 +33,8 @@ Les options de recherches sont :
|
|||
le mode d'affichage condensé au lieu du mode détaillé (défaut %(limit_aff_details)i)
|
||||
-L <num> ou --limit-historique=<num> : limitation du nombre de lignes
|
||||
d'historique affichées (défaut %(limit_aff_historique)i)
|
||||
|
||||
* particularités
|
||||
recherche sur prise possible (utiliser uniquement ce champ dans ce cas)
|
||||
"""
|
||||
|
||||
try:
|
||||
|
@ -307,12 +308,7 @@ def adher_details(adher) :
|
|||
else :
|
||||
# Chambre + prise (d'après annuaire)
|
||||
f += coul(u'Chambre : ','gras') + u"%s " % chbre
|
||||
prise = adher.prise()
|
||||
if prise :
|
||||
f += u'(prise %s' % prise
|
||||
f += prise_etat(chbre)
|
||||
f += ')'
|
||||
|
||||
f += '(%s)' % prise_etat(adher.chbre())
|
||||
f += '\n'
|
||||
|
||||
# Etudes
|
||||
|
@ -460,11 +456,7 @@ def club_details(club) :
|
|||
|
||||
# Chambre + prise
|
||||
f += coul(u'Local : ','gras') + "%s " % club.local()
|
||||
prise = club.prise()
|
||||
if prise :
|
||||
f += '(prise %s' % prise
|
||||
f += prise_etat(club.chbre())
|
||||
f += ')'
|
||||
f += '(%s)' % prise_etat(club.chbre())
|
||||
f += '\n'
|
||||
|
||||
# Paiement
|
||||
|
@ -566,6 +558,7 @@ def prise_etat(chbre) :
|
|||
try :
|
||||
# On met aussi l'état
|
||||
conn = sw_chbre(chbre)
|
||||
f += 'prise %s' % conn.prise_brute
|
||||
result = conn.status()
|
||||
rows, cols = get_screen_size()
|
||||
if result['etat']=='up' :
|
||||
|
@ -605,7 +598,7 @@ def prise_etat(chbre) :
|
|||
f+= ', activée, lien non détecté'
|
||||
except :
|
||||
# Switch non manageable
|
||||
pass
|
||||
f = 'informations prise non disponibles'
|
||||
|
||||
return f
|
||||
|
||||
|
@ -722,6 +715,29 @@ def __recherche() :
|
|||
|
||||
if only_adh + only_mac + only_club + only_bornes > 1 :
|
||||
__usage_brief('Options utilisées incompatibles')
|
||||
|
||||
arg = ' '.join(arg)
|
||||
# Cas particulier de recherche sur prise
|
||||
if arg.count('=') == 1 and arg.split('=')[0] == 'prise' :
|
||||
prise = arg.split('=')[1]
|
||||
# Récupération de la chambre
|
||||
try :
|
||||
from annuaires import reverse
|
||||
chbre = reverse(prise[0].lower())[prise[1:]]
|
||||
except :
|
||||
try :
|
||||
chbre = reverse(prise[0].lower())[prise[1:]+'-']
|
||||
except :
|
||||
print "Prise inconnue."
|
||||
return
|
||||
if len(chbre) != 1 :
|
||||
print "Prise correspondante à plusieurs prises %s " % ' '.join(chbre)
|
||||
return
|
||||
|
||||
# On fait la recherche sur la prise
|
||||
chbre= prise[0] + chbre[0]
|
||||
#print "Recherche sur chambre %s" % chbre
|
||||
arg = 'chbre=%s' % chbre
|
||||
|
||||
try :
|
||||
if only_crans :
|
||||
|
@ -730,13 +746,20 @@ def __recherche() :
|
|||
if not arg :
|
||||
# Pas de chaine de recherche fournie
|
||||
__usage_brief('Chaine de recherche incorrecte.')
|
||||
res = base.search(' '.join(arg))
|
||||
res = base.search(arg)
|
||||
except ValueError, c :
|
||||
__usage_brief(c.args[0])
|
||||
|
||||
# Traitement du résultat
|
||||
if not res['adherent'] and not res['machine'] and not res['club']:
|
||||
print "Aucun résultat trouvé."
|
||||
# Pas de résultat dans la base
|
||||
# Recherche sur chambre ?
|
||||
if arg.count('=') == 1 and arg.split('=')[0] == 'chbre' :
|
||||
# Affichage des infos de la chambre
|
||||
chbre = arg.split('=')[1]
|
||||
print "Chambre %s inocupée (%s)" % (chbre,prise_etat(chbre))
|
||||
else :
|
||||
print "Aucun résultat trouvé."
|
||||
sys.exit(3)
|
||||
# L'affichage souhaité a été précisé ?
|
||||
elif only_bornes :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue