示例#1
0
 def activate(self):
     """ Grab all setups and configurations from saves and caches."""
     EmpAlarm.activate(self)
     logging.debug("Activating the ExecAlarm, now loading")
     self.__load() # load all internal variables via saved config files
     logging.debug("Setting up execalarm internals")
     self.__setup() # setup all the alarms based on internal vars
示例#2
0
 def __init__(self, config):
     """Sets up the alerter."""
     EmpAlarm.__init__(self, config)
     self.__savedir = ""
     self.__alerts  = []
     self.__root    = None 
     self.__commands = [Command("add",trigger=self.addAlarm,   help="Adds a program to be turned into an alarm."),
                        Command("rm", trigger=self.removeAlarm,help="Removes a program that ExecAlarm uses."),
                        Command("lst",trigger=self.listAlarms, help="Lists all the programs ExecAlarm has available."),
                        Command("rename",trigger=self.renameAlarm, help="Rename the name that ExecAlarm uses.")]
示例#3
0
 def save(self):
     """ Save all internal variables as xml file in Attachment's cache. """
     EmpAlarm.save(self)
     try:
         
         if self.__root is None:
             self.__root = ET.Element("alerts")
             for alert in self.__alerts:
                 self.config.setgroup(alert.asCfgDict(), alert.groupid)
                 self.__root.append(alert.asXMLNode())
         else: logging.error("tried to save, but root wasn't null")
         tree = ET.ElementTree(self.__root)
         self.__makeBackup()
         with open(self.__savedir+"alarms.xml", "wb") as savefile:
             tree.write(savefile)
         self.__removeBackup()
     except Exception as e:
         logging.error("Couldn't save the alerts for %s: %s" % (self.ID, e))
         self.__restoreBackup()
示例#4
0
 def deactivate(self):
     """ We need to reset all of our variables when they get back."""
     EmpAlarm.deactivate(self)
     self.__alerts = []
     self.__root   = None
示例#5
0
 def save(self):
     EmpAlarm.save(self)
示例#6
0
 def __init__(self, conf):
     """Sets up the alerter."""
     EmpAlarm.__init__(self, conf)