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 :
|
try :
|
||||||
bat = chbre[0].lower()
|
bat = chbre[0].lower()
|
||||||
prise = chbre_prises[bat][chbre[1:]]
|
prise = chbre_prises[bat][chbre[1:]]
|
||||||
|
self.prise_brute = prise
|
||||||
self.switch = 'bat%s' % bat
|
self.switch = 'bat%s' % bat
|
||||||
num_switch = int(prise[0])
|
num_switch = int(prise[0])
|
||||||
if num_switch != 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)
|
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
|
-L <num> ou --limit-historique=<num> : limitation du nombre de lignes
|
||||||
d'historique affichées (défaut %(limit_aff_historique)i)
|
d'historique affichées (défaut %(limit_aff_historique)i)
|
||||||
|
* particularités
|
||||||
|
recherche sur prise possible (utiliser uniquement ce champ dans ce cas)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -307,12 +308,7 @@ def adher_details(adher) :
|
||||||
else :
|
else :
|
||||||
# Chambre + prise (d'après annuaire)
|
# Chambre + prise (d'après annuaire)
|
||||||
f += coul(u'Chambre : ','gras') + u"%s " % chbre
|
f += coul(u'Chambre : ','gras') + u"%s " % chbre
|
||||||
prise = adher.prise()
|
f += '(%s)' % prise_etat(adher.chbre())
|
||||||
if prise :
|
|
||||||
f += u'(prise %s' % prise
|
|
||||||
f += prise_etat(chbre)
|
|
||||||
f += ')'
|
|
||||||
|
|
||||||
f += '\n'
|
f += '\n'
|
||||||
|
|
||||||
# Etudes
|
# Etudes
|
||||||
|
@ -460,11 +456,7 @@ def club_details(club) :
|
||||||
|
|
||||||
# Chambre + prise
|
# Chambre + prise
|
||||||
f += coul(u'Local : ','gras') + "%s " % club.local()
|
f += coul(u'Local : ','gras') + "%s " % club.local()
|
||||||
prise = club.prise()
|
f += '(%s)' % prise_etat(club.chbre())
|
||||||
if prise :
|
|
||||||
f += '(prise %s' % prise
|
|
||||||
f += prise_etat(club.chbre())
|
|
||||||
f += ')'
|
|
||||||
f += '\n'
|
f += '\n'
|
||||||
|
|
||||||
# Paiement
|
# Paiement
|
||||||
|
@ -566,6 +558,7 @@ def prise_etat(chbre) :
|
||||||
try :
|
try :
|
||||||
# On met aussi l'état
|
# On met aussi l'état
|
||||||
conn = sw_chbre(chbre)
|
conn = sw_chbre(chbre)
|
||||||
|
f += 'prise %s' % conn.prise_brute
|
||||||
result = conn.status()
|
result = conn.status()
|
||||||
rows, cols = get_screen_size()
|
rows, cols = get_screen_size()
|
||||||
if result['etat']=='up' :
|
if result['etat']=='up' :
|
||||||
|
@ -605,7 +598,7 @@ def prise_etat(chbre) :
|
||||||
f+= ', activée, lien non détecté'
|
f+= ', activée, lien non détecté'
|
||||||
except :
|
except :
|
||||||
# Switch non manageable
|
# Switch non manageable
|
||||||
pass
|
f = 'informations prise non disponibles'
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
@ -722,6 +715,29 @@ def __recherche() :
|
||||||
|
|
||||||
if only_adh + only_mac + only_club + only_bornes > 1 :
|
if only_adh + only_mac + only_club + only_bornes > 1 :
|
||||||
__usage_brief('Options utilisées incompatibles')
|
__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 :
|
try :
|
||||||
if only_crans :
|
if only_crans :
|
||||||
|
@ -730,13 +746,20 @@ def __recherche() :
|
||||||
if not arg :
|
if not arg :
|
||||||
# Pas de chaine de recherche fournie
|
# Pas de chaine de recherche fournie
|
||||||
__usage_brief('Chaine de recherche incorrecte.')
|
__usage_brief('Chaine de recherche incorrecte.')
|
||||||
res = base.search(' '.join(arg))
|
res = base.search(arg)
|
||||||
except ValueError, c :
|
except ValueError, c :
|
||||||
__usage_brief(c.args[0])
|
__usage_brief(c.args[0])
|
||||||
|
|
||||||
# Traitement du résultat
|
# Traitement du résultat
|
||||||
if not res['adherent'] and not res['machine'] and not res['club']:
|
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)
|
sys.exit(3)
|
||||||
# L'affichage souhaité a été précisé ?
|
# L'affichage souhaité a été précisé ?
|
||||||
elif only_bornes :
|
elif only_bornes :
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue