Ejemplo n.º 1
0
 def setup(self):
     channel = self.channel.format(server=self.parent.server_name)
     self.factory = RedisFactory(self, channel)
     reactor.connectTCP(self.host, self.port, self.factory)
     for ev in self.relay_events.split(','):
         ty = events.get_by_name(ev.strip())
         if ty:
             self.register(self.on_event, ty)
         else:
             self.console("redis: couldn't bind to event: {0}".format(ev))
Ejemplo n.º 2
0
    def setup(self):
        endpoint = "tcp://%s:%s" % (self.host, self.port)
        zf = ZmqFactory()
        ze = ZmqEndpoint(ZmqEndpointType.bind, endpoint)
        self.zcon = ZmqPubConnection(zf, ze)

        for ev in self.relay_events.split(','):
            ty = events.get_by_name(ev.strip())
            if ty:
                self.register(self.on_event, ty)
            else:
                self.console("zeromq: couldn't bind to event: {0}".format(ev))
Ejemplo n.º 3
0
 def __init__(self, plugin, line):
     self.plugin = plugin
     
     line = line.strip()
     if line.startswith('@'):
         self.type = "event"
         event_name, command = re.match(r'^@([^\s]+)\s+(.+)$', line).groups()
         event = events.get_by_name(event_name)
         if not event:
             raise ValueError("unknown event: %s" % event_name)
         self.plugin.register(lambda e: self.execute(command), event)
     else:
         self.type = "time"
         bits = re.split(r'\s+', line, 5)
         time_spec, self.command = bits[:5], bits[5]
         self.ranges = self.parse_time(time_spec)
Ejemplo n.º 4
0
    def __init__(self, plugin, line):
        self.plugin = plugin

        line = line.strip()
        if line.startswith('@'):
            self.type = "event"
            event_name, command = re.match(r'^@([^\s]+)\s+(.+)$',
                                           line).groups()
            event = events.get_by_name(event_name)
            if not event:
                raise ValueError("unknown event: %s" % event_name)
            self.plugin.register(lambda e: self.execute(command, e), event)
        else:
            self.type = "time"
            bits = re.split(r'\s+', line, 5)
            time_spec, self.command = bits[:5], bits[5]
            self.ranges = self.parse_time(time_spec)