Ejemplo n.º 1
0
 def __thaw__(frz):
     subscriberId, data = frz
     protocol, uri = data[0].split(None, 1)
     new = subscribers.SubscriberFactory(subscriberId, protocol, uri)
     for line in data[1:]:
         field, val = line.split(None, 1)
         new.parse(field, val)
     return new
Ejemplo n.º 2
0
    def testSubscribe(self):
        tup = self.addComponent('foo:source', '1').getNameVersionFlavor()
        s1 = subscribers.SubscriberFactory('foo', 'xmlrpc', 'unix:/tmp/foo')
        s2 = subscribers.SubscriberFactory('bam', 'xmlrpc', 'unix:/tmp/bar')
        s1.watchEvent('TROVE_EVENT_UPDATED')
        s2.watchEvent('TROVE_EVENT_UPDATED')
        db = self.openRmakeDatabase()
        db.subscriberStore.add(1, s1)
        db.subscriberStore.add(1, s2)
        db.commit()
        results = db.getSubscribersForEvents(1, [(('TROVE_EVENT_UPDATED', 4),
                                                  ((1, tup), 4, 'foo')),
                                                 (('TROVE_EVENT_UPDATED', 5),
                                                  ((1, tup), 5, 'foo'))])

        # make sure the results for the two events return the same subscriber
        # instances - we'll then be creating a reverse dict based on those
        # instances.
        assert (set(results['TROVE_EVENT_UPDATED',
                            4]) == set(results['TROVE_EVENT_UPDATED', 5]))
Ejemplo n.º 3
0
 def subscribe(self, jobId):
     subscriber = subscribers.SubscriberFactory('monitor_', 'xmlrpc',
                                                self.uri)
     subscriber.watchEvent('JOB_STATE_UPDATED')
     subscriber.watchEvent('JOB_LOG_UPDATED')
     if self.showTroveDetails:
         subscriber.watchEvent('TROVE_STATE_UPDATED')
         subscriber.watchEvent('TROVE_LOG_UPDATED')
         subscriber.watchEvent('TROVE_PREPARING_CHROOT')
     self.jobId = jobId
     self.subscriber = subscriber
     self.client.subscribe(jobId, subscriber)
     self.listener._primeOutput(self.jobId)
Ejemplo n.º 4
0
    def testSubscribers(self):
        s = subscribers.SubscriberFactory('foo', 'mailto', '*****@*****.**')
        s['toName'] = 'Blah'
        s.watchEvent('JOB_UPDATED')

        db = self.openRmakeDatabase()
        db.subscriberStore.add(1, s)
        db.subscriberStore.get(s.subscriberId)

        assert(s.matches('JOB_UPDATED'))
        assert(s.matches('JOB_UPDATED', 'Built'))
        assert(not s.matches('TROVE_UPDATED', 'Built'))

        s = db.subscriberStore.getMatches(1, [[('JOB_UPDATED', ''), 'foo']])['JOB_UPDATED', ''][0]
        assert(s.matches('JOB_UPDATED'))
        assert(s.uri == '*****@*****.**')
        assert(s['toName'] == 'Blah')
        assert(not db.subscriberStore.getMatches(1, [[('TROVE_UPDATED', ''), 'foo']]))
Ejemplo n.º 5
0
 def parseString(self, name, val):
     protocol, uri = val.split(None, 1)
     try:
         s = subscribers.SubscriberFactory(name, protocol, uri)
     except errors.RmakeError, err:
         raise ParseError(err)