Example #1
0
 def test_peers(self):
     p1 = NumbexPeer(user='******', auth='test',
             address=self.url, gitaddress=('127.0.0.1', 11111))
     p2 = NumbexPeer(user='******', auth='test',
             address=self.url, gitaddress=('127.0.0.1', 22222))
     p1.register()
     p2.register()
     t1 = threading.Thread(target=p1.mainloop)
     t2 = threading.Thread(target=p2.mainloop)
     t1.daemon = True
     t1.start()
     t2.daemon = True
     t2.start()
     time.sleep(2)
     self.assertEqual(p1.peers, [['127.0.0.1', 22222]])
     self.assertEqual(p2.peers, [['127.0.0.1', 11111]])
     p1.stop()
     p2.stop()
     time.sleep(1)
Example #2
0
 def p2p_start(self):
     if self.p2p_running:
         self.log.info("p2p already running")
         return False
     self.git.start_daemon(self.cfg.getint('GIT', 'daemon_port'))
     self.log.info("starting p2p peers")
     user = self.cfg.get('PEER', 'user')
     auth = self.cfg.get('PEER', 'auth')
     trackers = self.cfg.get('PEER', 'trackers').split()
     for track in trackers:
         peer = NumbexPeer(user=user, auth=auth, address=track,
             git=self.git, gitaddress=self.cfg.get('GIT', 'repo_url'))
         self.clients.append(peer)
         peer.register()
         t = threading.Thread(target=peer.mainloop)
         t.daemon = True
         t.start()
     self.p2p_running = True
     return True