Pour viter toute confusion future, on stocke les dates de blacklist en

nombre de secondes coules depuis Epoch.

darcs-hash:20060326040112-68412-f01c2b7b858e2b5ece65beac8b7943ad7919724c.gz
This commit is contained in:
glondu 2006-03-26 06:01:12 +02:00
parent 65b6a8768d
commit 22fc2f1c0a
3 changed files with 134 additions and 97 deletions

View file

@ -23,7 +23,8 @@ To = ['fred@crans.org' , 'glondu@crans.org', 'chove@crans.org']
import string, os, sys
from whos import aff
import time, signal, getopt
import signal, getopt
from time import strftime, strptime, localtime, mktime
import re
import affich_tools, config
@ -810,28 +811,33 @@ def confirm(clas) :
affich_tools.prompt(u"Appuyez sur ENTREE pour continuer")
def set_blackliste(clas) :
""" Edite ou ajoute un item de la blackliste """
""" Édite ou ajoute un item de la blackliste """
bl = clas.blacklist()
if not bl :
# Pas d'entrée à éditer
index = -1
else :
arg = u'--title "Edition blackliste de %s" ' % clas.Nom()
arg = u'--title "Édition blackliste de %s" ' % clas.Nom()
arg+= u'--menu "Choisir l\'entrée à éditer :" 0 0 0 '
arg+= u'"0" "Ajouter une nouvelle entrée" '
i = 1
for b in bl :
arg += '"%i" "%s" ' % (i, b)
champs = b.split('$')
arg += '"%i" "%s [%s]" ' % (i, champs[2], champs[3])
i += 1
annul , res = dialog(arg)
annul, res = dialog(arg)
if annul : return 1
index = int(res[0]) - 1
# Edition
if index != -1 :
t = clas.blacklist()[index].split(',')
# Édition
if index != -1:
t = clas.blacklist()[index].split('$')
if t[0] != 'now':
t[0] = strftime('%d/%m/%Y %H:%M', localtime(int(t[0])))
if t[1] != 'now' and t[1] != '-':
t[1] = strftime('%d/%m/%Y %H:%M', localtime(int(t[1])))
else :
t = [ 'now' , '-', '', '' ]
t = ['now', '-', '', '']
step = 1
while 1 :
@ -857,16 +863,37 @@ def set_blackliste(clas) :
arg+= u'"- pour fin indéterminée" 2 25 "" 0 0 0 0 '
arg+= u'"Les jours de début et de fin sont inclus." 3 1 "" 0 0 0 0 '
arg+= u'"Sanction : %s" 4 1 "" 0 0 0 0 ' % t[2]
arg+= u'"Commentaire : (ne pas mettre de virgule)" 5 1 "%s" 6 1 52 0 ' % t[3]
arg+= u'"Commentaire : " 5 1 "%s" 6 1 52 0 ' % t[3]
annul , r = dialog(arg)
if annul : return 1
# Ajout des heures
t[0] = r[0].strip()
if len(t[0]) == 10 : t[0] += ' 00:00'
if len(t[0]) == 10: t[0] += ' 00:00'
t[1] = r[1].strip()
if len(t[1]) == 10 : t[1] += ' 23:59'
if len(t[1]) == 10: t[1] += ' 23:59'
# Vérification des heures
try:
if t[0] != 'now':
t[0] = int(mktime(strptime(t[0], '%d/%m/%Y %H:%M')))
except:
arg = u'--title "Erreur" '
arg+= u'--msgbox "Heure de début incorrecte (%s)\n\n\n" 0 0' % t[0]
dialog(arg)
step -= 1
continue
try:
if t[1] != 'now' and t[1] != '-':
t[1] = int(mktime(strptime(t[1], '%d/%m/%Y %H:%M')))
except:
arg = u'--title "Erreur" '
arg+= u'--msgbox "Heure de fin incorrecte (%s)\n\n\n" 0 0' % t[1]
dialog(arg)
step -= 1
continue
# Commentaire
c = r[2].strip()
login = script_utilisateur
@ -882,7 +909,7 @@ def set_blackliste(clas) :
if index == -1 :
clas.blacklist(t)
else :
clas.blacklist( ( index, t ) )
clas.blacklist(( index, t ))
step += 1
except ValueError, c :
arg = u'--title "Erreur" '
@ -2038,7 +2065,7 @@ Subject: Bugreport %s
# Erreur trop tot probablement
serv = ''
if serv :
mn = int(time.strftime('%M'))
mn = int(strftime('%M'))
# Restart toutes les 10 min : 03, 13, 23, 33, 43, 53
t = ( 13 - mn % 10 ) % 10 + 1 # Certaines machines le font -Aà 4-b
if t == 0 : t = 10