Ejemplo n.º 1
0
    def setUp(self):
        self.l = []
        self.startport = 4088
        for i in range(self.num):
            self.l.append(
                Khashmir('127.0.0.1', self.startport + i,
                         '/tmp/%s.test' % (self.startport + i)))
        reactor.iterate()
        reactor.iterate()

        for i in self.l:
            i.addContact('127.0.0.1', self.l[randrange(0, self.num)].port)
            i.addContact('127.0.0.1', self.l[randrange(0, self.num)].port)
            i.addContact('127.0.0.1', self.l[randrange(0, self.num)].port)
            reactor.iterate()
            reactor.iterate()
            reactor.iterate()

        for i in self.l:
            self.done = 0
            i.findCloseNodes(self._done)
            while not self.done:
                reactor.iterate()
        for i in self.l:
            self.done = 0
            i.findCloseNodes(self._done)
            while not self.done:
                reactor.iterate()
Ejemplo n.º 2
0
    def __init__(self):
        BigWorld.Base.__init__(self)
        print "Base: Guard.__init__"
        self.cellData["position"] = (whrandom.randrange(-1, 1), 0,
                                     whrandom.randrange(-1, 1))

        self.createInDefaultSpace()
Ejemplo n.º 3
0
    def testStoreRetrieve(self):
        for i in range(10):
            K = khash.newID()
            V = khash.newID()

            for a in range(3):
                self.done = 0

                def _scb(val):
                    self.done = 1

                self.l[randrange(0, self.num)].storeValueForKey(K, V, _scb)
                while not self.done:
                    reactor.iterate()

                def _rcb(val):
                    if not val:
                        self.done = 1
                        self.assertEqual(self.got, 1)
                    elif V in val:
                        self.got = 1

                for x in range(3):
                    self.got = 0
                    self.done = 0
                    self.l[randrange(0, self.num)].valueForKey(K, _rcb)
                    while not self.done:
                        reactor.iterate()
Ejemplo n.º 4
0
 def setUp(self):
     self.l = []
     self.startport = 4088
     for i in range(self.num):
         self.l.append(Khashmir('127.0.0.1', self.startport + i, '/tmp/%s.test' % (self.startport + i)))
     reactor.iterate()
     reactor.iterate()
     
     for i in self.l:
         i.addContact('127.0.0.1', self.l[randrange(0,self.num)].port)
         i.addContact('127.0.0.1', self.l[randrange(0,self.num)].port)
         i.addContact('127.0.0.1', self.l[randrange(0,self.num)].port)
         reactor.iterate()
         reactor.iterate()
         reactor.iterate() 
         
     for i in self.l:
         self.done = 0
         i.findCloseNodes(self._done)
         while not self.done:
             reactor.iterate()
     for i in self.l:
         self.done = 0
         i.findCloseNodes(self._done)
         while not self.done:
             reactor.iterate()
Ejemplo n.º 5
0
    def testStoreRetrieve(self):
        for i in range(10):
            K = khash.newID()
            V = khash.newID()
            
            for a in range(3):
                self.done = 0
                def _scb(val):
                    self.done = 1
                self.l[randrange(0, self.num)].storeValueForKey(K, V, _scb)
                while not self.done:
                    reactor.iterate()


                def _rcb(val):
                    if not val:
                        self.done = 1
                        self.assertEqual(self.got, 1)
                    elif V in val:
                        self.got = 1
                for x in range(3):
                    self.got = 0
                    self.done = 0
                    self.l[randrange(0, self.num)].valueForKey(K, _rcb)
                    while not self.done:
                        reactor.iterate()
Ejemplo n.º 6
0
Archivo: knet.py Proyecto: csm/khashmir
 def setUp(self):
     self.kfiles()
     self.l = []
     for i in range(self.num):
         self.l.append(Khashmir('', self.startport + i, '/tmp/kh%s.db' % (self.startport + i)))
     reactor.iterate()
     reactor.iterate()
     
     for i in self.l:
         i.addContact(self.localip, self.l[randrange(0,self.num)].port)
         i.addContact(self.localip, self.l[randrange(0,self.num)].port)
         i.addContact(self.localip, self.l[randrange(0,self.num)].port)
         reactor.iterate()
         reactor.iterate()
         reactor.iterate() 
         
     for i in self.l:
         self.done = 0
         i.findCloseNodes(self._done)
         while not self.done:
             reactor.iterate()
     for i in self.l:
         self.done = 0
         i.findCloseNodes(self._done)
         while not self.done:
             reactor.iterate()
Ejemplo n.º 7
0
    def setUp(self):
        self.kfiles()
        self.l = []
        for i in range(self.num):
            self.l.append(
                Khashmir('', self.startport + i,
                         '/tmp/kh%s.db' % (self.startport + i)))
        reactor.iterate()
        reactor.iterate()

        for i in self.l:
            i.addContact(self.localip, self.l[randrange(0, self.num)].port)
            i.addContact(self.localip, self.l[randrange(0, self.num)].port)
            i.addContact(self.localip, self.l[randrange(0, self.num)].port)
            reactor.iterate()
            reactor.iterate()
            reactor.iterate()

        for i in self.l:
            self.done = 0
            i.findCloseNodes(self._done)
            while not self.done:
                reactor.iterate()
        for i in self.l:
            self.done = 0
            i.findCloseNodes(self._done)
            while not self.done:
                reactor.iterate()
Ejemplo n.º 8
0
def cookieFunction():
    return COOKIES[whrandom.randrange(0, len(COOKIES))]
Ejemplo n.º 9
0
def randomFunction():
    return str(whrandom.randrange(0, 100))
Ejemplo n.º 10
0
 def timerEvent(self, ev):
     self.pixmap.update(whrandom.randrange(0, 300))
     bitBlt(self, 0, 0, self.pixmap, 0, 0, self.width(), self.height())