[services] Appel une seule fois à time.time() lors d'une recherche pour reconfiguration
This commit is contained in:
parent
3f1712e908
commit
7df0a4e1a0
1 changed files with 11 additions and 4 deletions
15
services.py
15
services.py
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import ldap
|
||||
import socket
|
||||
import time
|
||||
import lc_ldap
|
||||
import attributs
|
||||
import objets
|
||||
|
@ -32,6 +32,11 @@ services_to_objects['create']={}
|
|||
services_to_objects['create']['home'] = [objets.adherent, objets.club]
|
||||
services_to_objects['delete']['del_user'] = [objets.adherent, objets.club]
|
||||
|
||||
NOW = time.time()
|
||||
|
||||
def update_now():
|
||||
global NOW
|
||||
NOM = time.time()
|
||||
|
||||
def services_to_args_mail_modif(x):
|
||||
if isinstance(x, attributs.droits):
|
||||
|
@ -131,7 +136,7 @@ def services_to_time_mail_bienvenue(x):
|
|||
else:
|
||||
return []
|
||||
if u'cransAccount' in [ str(o) for o in adh['objectClass']]:
|
||||
return [ time.time() + 660 ]
|
||||
return [ NOW + 660 ]
|
||||
else:
|
||||
return [ 0 ]
|
||||
|
||||
|
@ -235,7 +240,7 @@ def service_to_restart(conn, new=None, args=[], start=0):
|
|||
return
|
||||
keep_date = []
|
||||
for date in serv_dates[new[1:]]:
|
||||
if time.time() < int(date):
|
||||
if NOW < int(date):
|
||||
keep_date.append(date)
|
||||
if keep_date:
|
||||
mods = [{'start': serv_dates[new[1:]]}, { 'start': keep_date }]
|
||||
|
@ -304,6 +309,8 @@ def service_to_restart(conn, new=None, args=[], start=0):
|
|||
def services_to_restart(conn, old_attrs={}, new_attrs={}, created_object=[], deleted_object=[]):
|
||||
"""Détermine quels sont les services à reconfigurer"""
|
||||
|
||||
update_now()
|
||||
|
||||
# On tranforme les dico *_attrs du type string -> attr en *_attrs_c du type class -> attr
|
||||
old_attrs_c = dict((attributs.AttributeFactory.get(key), value) for key,value in old_attrs.items() if attributs.AttributeFactory.get(key, fallback=None) != None and value)
|
||||
new_attrs_c = dict((attributs.AttributeFactory.get(key), value) for key,value in new_attrs.items() if attributs.AttributeFactory.get(key, fallback=None) != None and value)
|
||||
|
@ -397,7 +404,7 @@ class Service:
|
|||
def __unicode__(self):
|
||||
starting = self.start
|
||||
starting.sort()
|
||||
dates = u' et '.join(map(lambda t: t < time.time() and \
|
||||
dates = u' et '.join(map(lambda t: t < NOW and \
|
||||
u"maintenant" or time.strftime(date_format,
|
||||
time.localtime(t)),
|
||||
self.start))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue