Recherche sur les machines du crans.

darcs-hash:20040908200329-41617-24cc613b96dd7a39a4cb6afcfd711f89e60a5d0b.gz
This commit is contained in:
pauget 2004-09-08 22:03:29 +02:00
parent 2678597ba9
commit e836f23215

View file

@ -19,11 +19,12 @@ Les champs de recherche possibles sont :
%(champs_rech)s
Les options de recherches sont :
* limitations sur la recherche :
* limitations sur l'affichage :
-a ou --adherent : limitation de l'affichage aux adhérents
-m ou --machine : limitation de l'affichage aux machines
-c ou --club : limitation de l'affichage aux clubs
-b ou --bornes : limitation de l'affichage aux bornes wifi
--crans : recherche uniquement les machines du crans
* options d'affichage :
-t ou --tech : affichages des infos techniques des machines
à la place des infos administratives dans les résumés.
@ -35,7 +36,7 @@ d'historique affich
"""
from ldap_crans import is_actif , crans_ldap, ann_scol
from ldap_crans import is_actif , crans_ldap, ann_scol, crans
from affich_tools import *
limit_aff_details = 1
@ -587,7 +588,7 @@ def __recherche() :
__usage_brief()
try :
options, arg = getopt.getopt(sys.argv[1:], 'hamctbil:L:', [ 'debug', 'help', 'adherent', 'machine', 'club' , 'tech', 'bornes', 'limit=', 'limit-historique=', 'ipsec' ])
options, arg = getopt.getopt(sys.argv[1:], 'hamctbil:L:', [ 'debug', 'help', 'adherent', 'machine', 'club' , 'tech', 'bornes', 'limit=', 'limit-historique=', 'ipsec', 'crans' ])
except getopt.error, msg :
__usage_brief(msg)
@ -596,6 +597,7 @@ def __recherche() :
only_mac=0
only_club=0
only_bornes=0
only_crans=0
mtech = 0
for opt, val in options :
@ -623,6 +625,10 @@ def __recherche() :
elif opt in [ '-c', '--club' ] :
only_club = 1
print "Affichage limité aux clubs."
elif opt == '--crans' :
only_crans = 1
mtech = 1
print "Affichage limité aux machines du crans."
elif opt in [ '-b', '--bornes' ] :
only_bornes = 1
print "Affichage limité aux bornes wifi."
@ -632,7 +638,7 @@ def __recherche() :
arg = [ 'canal=*' ]
elif arg[0].find('=')!=-1 :
# Recherche avec critères
arg += [ 'canal=*' ]
arg += [ '&canal=*' ]
elif opt in [ '-t', '--tech' ] :
# Format affichage des machines
mtech = 1
@ -643,11 +649,13 @@ def __recherche() :
if only_adh + only_mac + only_club + only_bornes > 1 :
__usage_brief('Options utilisées incompatibles')
try :
if only_crans :
res = { 'machine' : crans().machines() , 'adherent' : [] , 'club' : [] }
else :
if not arg :
# Pas de chaine de recherche fournie
__usage_brief('Chaine de recherche incorrecte.')
try :
res = base.search(' '.join(arg))
except ValueError, c :
__usage_brief(c.args[0])