def queue_msg(self, channel): monitored_sample = channel.get() if not self.started_flag: raise Exception("Cannot queue message, presentation is stopped") if monitored_sample.value: cm = self.__core.get_service("channel_manager") cdb = cm.channel_database_get() frm = SettingsBase.get_setting(self, 'from_address') to = SettingsBase.get_setting(self, 'to_address') sbj = SettingsBase.get_setting(self, 'subject') msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % \ (frm, to, sbj) msg += dump_channel_db_as_text(cdb) self.queue.put(msg)
def queue_msg(self, channel): monitored_sample = channel.get() if not self.started_flag: raise Exception("Cannot queue message, presentation is stopped") if monitored_sample.value: channel_manager = self.__core.get_service("channel_manager") channel_database = channel_manager.channel_database_get() frm = SettingsBase.get_setting(self, 'from_address') to = SettingsBase.get_setting(self, 'to_address') sbj = SettingsBase.get_setting(self, 'subject') msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % \ (frm, to, sbj) msg += dump_channel_db_as_text(channel_database) self.queue.put(msg)
def queue_msg(self, channel): """ Call back for the channel publisher's __notify function. If the sample from the channel evaluates to boolean True, queues message """ monitored_sample = channel.get() notify_cooldown_time = SettingsBase.get_setting(self, 'notify_cooldown_time') if not self.started_flag: raise Exception("Cannot queue message, presentation is stopped") if monitored_sample.value: if time.clock()-self.LastNotify > notify_cooldown_time: self.LastNotify = time.clock() cm = self.__core.get_service("channel_manager") cdb = cm.channel_database_get() try: status, output = digicli.digicli('show net') if status: for line in output: if line.find('MAC Address') >= 0: l = line.split() #print "".join(l[1:]).strip() gatewayID = l[3] #print "Gateway ID : %s" % gatewayID status, output = digicli.digicli('show system') if status: for line in output: if line.find('description') >= 0: l = line.split(':') descr = l[1] #print "Gateway ID : %s" % gatewayID except: print "SMTP Alarm: can't get the Gateway ID..." frm = SettingsBase.get_setting(self, 'from_address') to = SettingsBase.get_setting(self, 'to_address') sbj = SettingsBase.get_setting(self, 'subject') msg = "From: %s\r\nTo: %s\r\nSubject: %s from %s - %s\r\n\r\n " % \ (frm, to, sbj, gatewayID, descr) msg += dump_channel_db_as_text(cdb) self.queue.put(msg)
def __write_channel_database(self, cdb, startswith=""): if len(cdb.channel_list()) > 0: self.write(dump_channel_db_as_text(cdb, startswith)) else: self.write("\r\n\tChannelDatabase is empty.\r\n")
def __write_channel_database(self, cdb, startswith=""): if len(cdb.channel_list()) > 0: self.write(dump_channel_db_as_text(cdb, startswith)) else: self.write("\r\n\tChannelDatabase is empty.\r\n")