From e836f23215fb38cbef528e42883263d19088e1b4 Mon Sep 17 00:00:00 2001 From: pauget Date: Wed, 8 Sep 2004 22:03:29 +0200 Subject: [PATCH] Recherche sur les machines du crans. darcs-hash:20040908200329-41617-24cc613b96dd7a39a4cb6afcfd711f89e60a5d0b.gz --- gestion/whos.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/gestion/whos.py b/gestion/whos.py index 89724cc5..056c8d67 100755 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -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 @@ -642,13 +648,15 @@ def __recherche() : if only_adh + only_mac + only_club + only_bornes > 1 : __usage_brief('Options utilisées incompatibles') - - if not arg : - # Pas de chaine de recherche fournie - __usage_brief('Chaine de recherche incorrecte.') try : - res = base.search(' '.join(arg)) + 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.') + res = base.search(' '.join(arg)) except ValueError, c : __usage_brief(c.args[0])