L'erreur que renvoie getopt n'est pas en unicode.

darcs-hash:20060404215742-9e428-ed112a6eaf2f5d57e80ca4e7f7014d85ab5f2601.gz
This commit is contained in:
bobot 2006-04-04 23:57:42 +02:00
parent cc394f30c7
commit bf58f3db6c

View file

@ -932,7 +932,8 @@ def __recherche() :
try : try :
options, arg = getopt.getopt(sys.argv[1:], 'hamctbil:L:', [ 'debug', 'help', 'adherent', 'machine', 'club' , 'tech', 'bornes', 'limit=', 'limit-historique=', 'ipsec', 'crans' ]) 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 : except getopt.error, msg :
__usage_brief(msg) __usage_brief(unicode(msg))
# Traitement des options # Traitement des options
only_adh=0 only_adh=0
@ -952,12 +953,12 @@ def __recherche() :
# Passage mode condensé, mode détaillé # Passage mode condensé, mode détaillé
try : limit_aff_details = int(val) try : limit_aff_details = int(val)
except : except :
__usage_brief('Valeur du paramètre %s incorecte (doit être un entier positif)' % opt) __usage_brief(u'Valeur du paramètre %s incorecte (doit être un entier positif)' % opt)
elif opt == '-L' or opt =='--limit-historique': elif opt == '-L' or opt =='--limit-historique':
# Limitation du nombre de lignes d'historique # Limitation du nombre de lignes d'historique
try : limit_aff_historique = int(val) try : limit_aff_historique = int(val)
except : except :
__usage_brief('Valeur du paramètre %s incorecte (doit être un entier positif)' % opt) __usage_brief(u'Valeur du paramètre %s incorecte (doit être un entier positif)' % opt)
elif opt in [ '-a', '--adherent' ] : elif opt in [ '-a', '--adherent' ] :
only_adh = 1 only_adh = 1
cprint(u"Affichage limité aux adhérents.") cprint(u"Affichage limité aux adhérents.")
@ -989,7 +990,7 @@ def __recherche() :
aff_ipsec = 1 aff_ipsec = 1
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(u'Options utilisées incompatibles')
arg = ' '.join(arg) arg = ' '.join(arg)
# Cas particulier de recherche sur prise # Cas particulier de recherche sur prise
@ -1012,7 +1013,7 @@ def __recherche() :
# On fait la recherche sur la chambre # On fait la recherche sur la chambre
chbre= prise[0] + chbre[0] chbre= prise[0] + chbre[0]
#cprint(u"Recherche sur chambre %s" % chbre) #cprint(u"Recherche sur chambre %s" % chbre)
arg = 'chbre=%s' % chbre arg = u'chbre=%s' % chbre
# sinon on ne fait rien et on recherche sur le champ prise # sinon on ne fait rien et on recherche sur le champ prise
try: try:
@ -1021,7 +1022,7 @@ def __recherche() :
else : else :
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(u'Chaine de recherche incorrecte.')
res = base.search(arg) res = base.search(arg)
except ValueError, c : except ValueError, c :
__usage_brief(c.args[0]) __usage_brief(c.args[0])