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
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.")]
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()
def deactivate(self): """ We need to reset all of our variables when they get back.""" EmpAlarm.deactivate(self) self.__alerts = [] self.__root = None
def save(self): EmpAlarm.save(self)
def __init__(self, conf): """Sets up the alerter.""" EmpAlarm.__init__(self, conf)