示例#1
0
class Notifier:
    def __init__(self, config, notifierModules):
        LOGGER.info("starting logger module")
        print str(notifierModules)
        self.moduleLoader = DynamicModule(notifierModules)
        self.modules = []
        for m in self.moduleLoader.load():
            self.modules.append(m["class"]())
        self.rabbitConsumer = RabbitConsumer("module.notifier", "module.notifier")
        try:
            self.setHandlers()
            self.rabbitConsumer.start()
            while True:
                  time.sleep(0.2)
        except KeyboardInterrupt:
            print("stopping consuming")
            self.rabbitConsumer.stop()
            print("see ya later!")
            sys.exit(0)
    def notifySuccess(self, message):
        print str(message)
        if len(self.modules) > 0:
            self.modules[0].notifySuccess(message)
    def setHandlers(self):
        print "set handlers"
        LOGGER.info("set handlers")
        self.rabbitConsumer.addHandler("success", self.notifySuccess)
示例#2
0
 def __init__(self, config, notifierModules):
     LOGGER.info("starting logger module")
     print str(notifierModules)
     self.moduleLoader = DynamicModule(notifierModules)
     self.modules = []
     for m in self.moduleLoader.load():
         self.modules.append(m["class"]())
     self.rabbitConsumer = RabbitConsumer("module.notifier", "module.notifier")
     try:
         self.setHandlers()
         self.rabbitConsumer.start()
         while True:
               time.sleep(0.2)
     except KeyboardInterrupt:
         print("stopping consuming")
         self.rabbitConsumer.stop()
         print("see ya later!")
         sys.exit(0)