comparison src/tools/misc.py @ 993:301b342c697a

core: use of the new core.log module: /!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
author Goffi <goffi@goffi.org>
date Sat, 19 Apr 2014 19:19:19 +0200
parents 65bf1bc70f6b
children ba41a81d14c2
comparison
equal deleted inserted replaced
992:f51a1895275c 993:301b342c697a
19 19
20 """Misc usefull classes""" 20 """Misc usefull classes"""
21 21
22 from sat.core.i18n import _ 22 from sat.core.i18n import _
23 import sys 23 import sys
24 from logging import debug, warning 24 from sat.core.log import getLogger
25 log = getLogger(__name__)
25 26
26 27
27 class TriggerException(Exception): 28 class TriggerException(Exception):
28 pass 29 pass
29 30
53 """ 54 """
54 if point_name not in self.__triggers: 55 if point_name not in self.__triggers:
55 self.__triggers[point_name] = [] 56 self.__triggers[point_name] = []
56 if priority != 0 and priority in [trigger_tuple[0] for trigger_tuple in self.__triggers[point_name]]: 57 if priority != 0 and priority in [trigger_tuple[0] for trigger_tuple in self.__triggers[point_name]]:
57 if priority in (self.MIN_PRIORITY, self.MAX_PRIORITY): 58 if priority in (self.MIN_PRIORITY, self.MAX_PRIORITY):
58 warning(_("There is already a bound priority [%s]") % point_name) 59 log.warning(_("There is already a bound priority [%s]") % point_name)
59 else: 60 else:
60 debug(_("There is already a trigger with the same priority [%s]") % point_name) 61 log.debug(_("There is already a trigger with the same priority [%s]") % point_name)
61 self.__triggers[point_name].append((priority, callback)) 62 self.__triggers[point_name].append((priority, callback))
62 self.__triggers[point_name].sort(key=lambda trigger_tuple: 63 self.__triggers[point_name].sort(key=lambda trigger_tuple:
63 trigger_tuple[0], reverse=True) 64 trigger_tuple[0], reverse=True)
64 65
65 def remove(self, point_name, callback): 66 def remove(self, point_name, callback):