コード例 #1
0
 def setUpPreSession(self):
     """ override TestAsServer """
     TestAsServer.setUpPreSession(self)
     # Enable buddycast
     self.config.set_buddycast(True)
     self.config.set_start_recommender(True)
     self.config.set_bartercast(True)
コード例 #2
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())        
        self.myhash = sha(self.mypermid).digest()
コード例 #3
0
 def tearDown(self):
     """ override TestAsServer """
     TestAsServer.tearDown(self)
     try:
         os.remove('randpool.dat')
     except:
         pass
コード例 #4
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)

        # Enable buddycast and crawler handling
        self.config.set_buddycast(True)
        self.config.set_crawler(True)
コード例 #5
0
    def setUp(self):
        """ override TestAsServer """
        print >>sys.stderr,"test: *** setup friendship"
        TestAsServer.setUp(self)

        self.usercallbackexpected = True
        self.usercallbackreceived = False
コード例 #6
0
 def tearDown(self):
     """ override TestAsServer """
     TestAsServer.tearDown(self)
     try:
         os.remove(self.superpeerfilename)
     except:
         print_exc()
コード例 #7
0
 def setUpPreSession(self):
     """ override TestAsServer """
     print >> sys.stderr,"test: Pre Tribler Init"
     TestAsServer.setUpPreSession(self)
     print >> sys.stderr,"test: Pre Tribler Init: config_path",self.config_path
     # Enable remote querying
     self.config.set_remote_query(True)
コード例 #8
0
 def tearDown(self):
     """ override TestAsServer """
     TestAsServer.tearDown(self)
     try:
         os.remove(self.superpeerfilename)
     except:
         print_exc()
コード例 #9
0
 def setUp(self):
     """ override TestAsServer """
     TestAsServer.setUp(self)
     print >>sys.stderr,"test: Giving Session time to startup"
     time.sleep(5)
     print >>sys.stderr,"test: Session should have started up"
     self.vod_started = False
コード例 #10
0
 def setUpPreSession(self):
     """ override TestAsServer """
     TestAsServer.setUpPreSession(self)
     # Enable buddycast
     self.config.set_buddycast(True)
     self.config.set_start_recommender(True)
     self.config.set_bartercast(True)
コード例 #11
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())  
        
        # Calculating the infohash for proxyservice.test.torrent
        self.torrentfile = os.path.join('extend_hs_dir','proxyservice.test.torrent')
        
        # Read torrentfile to calculate the infohash
        torrentfile_content = open(self.torrentfile, "rb")
        # Decode all the file
        metainfo = bdecode(torrentfile_content.read())
        # Re-encode only the info section
        self.infohash = hashlib.sha1(bencode(metainfo['info'])).digest()
        # Close the torrentfile
        torrentfile_content.close()
        
        # Add us as friend, so he will accept the ASK_FOR_HELP
        if False:  # TEMP
            friendsdb = FriendDBHandler.getInstance()
            friendsdb.addFriend(self.mypermid)
        else:
            self.session.set_overlay_request_policy(AllowAllRequestPolicy())
          
        self.session.set_download_states_callback(self.states_callback)
コード例 #12
0
 def tearDown(self):
     """ override TestAsServer """
     TestAsServer.tearDown(self)
     try:
         os.remove('randpool.dat')
     except:
         pass
コード例 #13
0
    def tearDown(self):
        """ override TestAsServer """
        print >> sys.stderr, "test: *** TEARDOWN"
        TestAsServer.tearDown(self)

        for i in range(self.NLISTENERS):
            self.myss[i].close()
コード例 #14
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())
        self.myhash = sha(self.mypermid).digest()
コード例 #15
0
 def setUpPreSession(self):
     """ override TestAsServer """
     print >> sys.stderr, "test: Pre Tribler Init"
     TestAsServer.setUpPreSession(self)
     print >> sys.stderr, "test: Pre Tribler Init: config_path", self.config_path
     # Enable remote querying
     self.config.set_remote_query(True)
コード例 #16
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())        
        self.myhash = sha(self.mypermid).digest()

        # Give Tribler some download history
        print >>sys.stderr,"test: Populating MYPREFERENCES table"
        self.myprefdb = self.session.open_dbhandler(NTFY_MYPREFERENCES)
        data = {'destination_path':'.'}
        infohashes = self.create_good_my_prefs(self,btconn.current_version)
        for i in range(0,len(infohashes)):
            commit = (i == len(infohashes)-1) 
            self.myprefdb.addMyPreference(infohashes[i], data, commit=commit)

        # Give Tribler some peers
        print >>sys.stderr,"test: Populating PEERS table"
        self.peerdb = self.session.open_dbhandler(NTFY_PEERS)
        past = int(time.time())-1000000000
        peers = self.create_good_random_peers(btconn.current_version,num=200)
        
        peers = []
        
        for i in range(0,len(peers)):
            peer = peers[i]
            peer.update({'last_seen':past, 'last_connected':past})
            del peer['connect_time']
            peer['num_torrents'] = peer['nfiles'] 
            del peer['nfiles']
            commit = (i == len(peers)-1)
            self.peerdb.addPeer(peer['permid'], peer, update_dns=True, update_connected=True, commit=commit)
コード例 #17
0
    def tearDown(self):
        """ override TestAsServer """
        print >> sys.stderr,"test: *** TEARDOWN"
        TestAsServer.tearDown(self)

        for i in range(self.NLISTENERS):
            self.myss[i].close()
コード例 #18
0
 def setUp(self):
     """ override TestAsServer """
     TestAsServer.setUp(self)
     print >>sys.stderr,time.asctime(),'-', "test: Giving Session time to startup"
     time.sleep(5)
     print >>sys.stderr,time.asctime(),'-', "test: Session should have started up"
     self.vod_started = False
コード例 #19
0
    def setUp(self):
        """ override TestAsServer """
        print >>sys.stderr,time.asctime(),'-', "test: *** setup friendship"
        TestAsServer.setUp(self)

        self.usercallbackexpected = True
        self.usercallbackreceived = False
コード例 #20
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())        

        self.setUpMyListenSocket()
コード例 #21
0
 def setUpPreSession(self):
     """ override TestAsServer """
     TestAsServer.setUpPreSession(self)
     
     self.config.set_overlay(False)
     self.config.set_internal_tracker(True)
     
     self.mylistenport = 4810
コード例 #22
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())        

        self.setUpMyListenSocket()
コード例 #23
0
ファイル: test_seeding.py プロジェクト: Swizec/IJS-stuff
 def setUpPreSession(self):
     """ override TestAsServer """
     TestAsServer.setUpPreSession(self)
     
     self.config.set_megacache(False)        
     self.config.set_internal_tracker(True)
     #self.config.set_tracker_nat_check(0)
     
     self.mylistenport = 4810
コード例 #24
0
    def setUpPreSession(self):
        """ override TestAsServer """
        print >> sys.stderr,"test: Pre Tribler Init"
        TestAsServer.setUpPreSession(self)
        print >> sys.stderr,"test: Pre Tribler Init: config_path",self.config_path
        # Enable dialback support
        self.config.set_dialback(True)
        self.config.set_buddycast(True) # make sure overlay connections are being made
        self.config.set_start_recommender(True)

        # Write superpeers.txt
        self.install_path = tempfile.mkdtemp()
        spdir = os.path.join(self.install_path, LIBRARYNAME, 'Core')
        os.makedirs(spdir)

        statsdir = os.path.join(self.install_path, LIBRARYNAME, 'Core', 'Statistics')
        os.makedirs(statsdir)
        
        superpeerfilename = os.path.join(spdir, 'superpeer.txt')
        print >> sys.stderr,"test: writing",self.NLISTENERS,"superpeers to",superpeerfilename
        f = open(superpeerfilename, "w")

        self.mylistenport = []
        self.myss = []
        self.mykeypairs = []
        self.mypermids = []
        for i in range(self.NLISTENERS):
            # Start our server side, to with Tribler will try to connect
            self.mylistenport.append(4810+i)
            self.myss.append(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
            self.myss[i].setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            self.myss[i].bind(('', self.mylistenport[i]))
            self.myss[i].listen(1)

            self.mykeypairs.append(EC.gen_params(EC.NID_sect233k1))
            self.mykeypairs[i].gen_key()
            self.mypermids.append(str(self.mykeypairs[i].pub().get_der()))

            content = '127.0.0.1, '+str(self.mylistenport[i])+', '+show_permid(self.mypermids[i])+', FakeSuperPeer\n'
            f.write(content)
        f.close()
        
        self.config.set_install_dir(self.install_path)
        
        srcfiles = []
        srcfiles.append(os.path.join(LIBRARYNAME,"schema_sdb_v"+str(CURRENT_MAIN_DB_VERSION)+".sql"))
        srcfiles.append(os.path.join(LIBRARYNAME,"Core","Statistics","tribler_seedingstats_sdb.sql"))
        srcfiles.append(os.path.join(LIBRARYNAME,"Core","Statistics","tribler_friendship_stats_sdb.sql"))
        srcfiles.append(os.path.join(LIBRARYNAME,"Core","Statistics","tribler_videoplayback_stats.sql"))
        for srcfile in srcfiles:
            sfn = os.path.join('..','..',srcfile)
            dfn = os.path.join(self.install_path,srcfile)
            print >>sys.stderr,"test: copying",sfn,dfn
            shutil.copyfile(sfn,dfn)

        """
コード例 #25
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)

        # Enable dialback
        self.config.set_dialback(True)
        # H4X0R: testing only
        self.config.sessconfig['dialback_active'] = 0

        self.setUpMyListenSocket()
コード例 #26
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())        
        self.myhash = sha(self.mypermid).digest()
        
        self.buddycast = BuddyCastFactory.getInstance(superpeer=True)
        self.buddycast.olthread_register(True)
コード例 #27
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())        
        self.myhash = sha(self.mypermid).digest()
        
        self.buddycast = BuddyCastFactory.getInstance(superpeer=True)
        self.buddycast.olthread_register(True)
コード例 #28
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)

        # Enable dialback
        self.config.set_dialback(True)
        # H4X0R: testing only
        self.config.sessconfig['dialback_active'] = 0

        self.setUpMyListenSocket()
コード例 #29
0
 def setUpPreSession(self):
     """ override TestAsServer """
     TestAsServer.setUpPreSession(self)
     # BuddyCast
     self.config.set_buddycast(True)
     self.config.set_start_recommender(True)
     
     fd,self.superpeerfilename = tempfile.mkstemp()
     os.write(fd,'')
     os.close(fd)
     self.config.set_superpeer_file(self.superpeerfilename)
コード例 #30
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)
        # BuddyCast
        self.config.set_buddycast(True)
        self.config.set_start_recommender(True)

        fd, self.superpeerfilename = tempfile.mkstemp()
        os.write(fd, '')
        os.close(fd)
        self.config.set_superpeer_file(self.superpeerfilename)
コード例 #31
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)
        self.hispermid = str(self.his_keypair.pub().get_der())
        self.my_permid = str(self.my_keypair.pub().get_der())

        self.content_name = 'Hallo S22E44'
        self.tdef = TorrentDef()
        self.tdef.set_tracker('http://localhost:0/announce')
        self.tdef.set_piece_length(2 ** 15)
        self.tdef.create_live(self.content_name,2 ** 16)
        self.tdef.finalize()
コード例 #32
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)
        self.hispermid = str(self.his_keypair.pub().get_der())
        self.my_permid = str(self.my_keypair.pub().get_der())

        self.content_name = 'Hallo S22E44'
        self.tdef = TorrentDef()
        self.tdef.set_tracker('http://localhost:0/announce')
        self.tdef.set_piece_length(2**15)
        self.tdef.create_live(self.content_name, 2**16)
        self.tdef.finalize()
コード例 #33
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)
        # Enable social networking
        self.config.set_social_networking(True)

        # Give him a usericon to send
        fn = self.make_filename('usericon-ok.jpg')
        f = open(fn, "rb")
        data = f.read()
        f.close()
        self.config.set_mugshot(data, 'image/jpeg')
コード例 #34
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)
        # Enable social networking
        self.config.set_social_networking(True)

        # Give him a usericon to send
        fn = self.make_filename('usericon-ok.jpg')
        f = open(fn,"rb")
        data = f.read()
        f.close()
        self.config.set_mugshot(data,'image/jpeg')
コード例 #35
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)

        self.setUpMyListenSockets()
        
        # Must be changed in test/extend_hs_dir/proxyservice.test.torrent as well
        self.mytrackerport = 4901
        self.myid = 'R410-----HgUyPu56789'
        self.mytracker = MyTracker(self.mytrackerport,self.myid,'127.0.0.1',self.mylistenport)
        self.mytracker.background_serve()

        self.myid2 = 'R410-----56789HuGyx0'
コード例 #36
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.my_permid = str(self.my_keypair.pub().get_der())
        self.my_hash = sha(self.my_permid).digest()
        self.his_permid = str(self.his_keypair.pub().get_der())        

        # Start our server side, to with Tribler will try to connect
        self.listen_port = 4123
        self.listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.listen_socket.bind(("", self.listen_port))
        self.listen_socket.listen(10)
        self.listen_socket.settimeout(10)
コード例 #37
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)
        self.config.set_buddycast(True)
        BuddyCastCore.TESTASSERVER = True
        ChannelCastCore.TESTASSERVER = True
        VoteCastCore.TESTASSERVER = True
        self.config.set_start_recommender(True)
        self.config.set_bartercast(True) 
        self.config.set_remote_query(True)
        self.config.set_crawler(False)       
        self.config.set_torrent_collecting_dir(os.path.join(self.config_path, "tmp_torrent_collecting"))
        
        self.collecting_dir = os.path.join(self.config_path, "temp_subtitles_collecting")
        os.makedirs(self.collecting_dir)
        self.config.set_subtitles_collecting(True)
        self.config.set_subtitles_collecting_dir(self.collecting_dir)
        
        

#        # Write superpeers.txt and DB schema
        self.install_path = tempfile.mkdtemp()
        spdir = os.path.join(self.install_path, LIBRARYNAME, 'Core')
        os.makedirs(spdir)

        statsdir = os.path.join(self.install_path, LIBRARYNAME, 'Core', 'Statistics')
        os.makedirs(statsdir)
        
        superpeerfilename = os.path.join(spdir, 'superpeer.txt')
        print >> sys.stderr,time.asctime(),'-', "test: writing empty superpeers to",superpeerfilename
        f = open(superpeerfilename, "w")
        f.write('# Leeg')
        f.close()

        self.config.set_install_dir(self.install_path)
        
        srcfiles = []
        srcfiles.append(os.path.join(LIBRARYNAME,"schema_sdb_v5.sql"))
        for srcfile in srcfiles:
            sfn = os.path.join('..','..',srcfile)
            dfn = os.path.join(self.install_path,srcfile)
            print >>sys.stderr,time.asctime(),'-', "test: copying",sfn,dfn
            shutil.copyfile(sfn,dfn)
            
        #copy subtitles files in the appropriate subtitles folder
        self.src1 = os.path.join(RES_DIR,'fake.srt')
        self.src2 = os.path.join(RES_DIR,'fake0.srt')
コード例 #38
0
ファイル: test_dlhelp.py プロジェクト: Anaconda84/Anaconda
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)

        self.setUpMyListenSockets()
        
        # Must be changed in test/extend_hs_dir/dummydata.merkle.torrent as well
        self.mytrackerport = 4901
        self.myid = 'R410-----HgUyPu56789'
        self.mytracker = MyTracker(self.mytrackerport,self.myid,'127.0.0.1',self.mylistenport)
        self.mytracker.background_serve()

        self.myid2 = 'R410-----56789HuGyx0'
        
        # Arno, 2009-12-15: Make sure coop downloads have their own destdir
        destdir = tempfile.mkdtemp()
        self.config.set_download_help_dir(destdir)
コード例 #39
0
ファイル: test_extend_hs.py プロジェクト: Swizec/IJS-stuff
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        # Let Tribler start downloading an non-functioning torrent, so
        # we can talk to a normal download engine.
        
        self.torrentfn = os.path.join('extend_hs_dir','dummydata.merkle.torrent')
        tdef = TorrentDef.load(self.torrentfn)

        dscfg = self.setUpDownloadConfig()
        
        self.session.start_download(tdef,dscfg)

        # This is the infohash of the torrent in test/extend_hs_dir
        self.infohash = '\xccg\x07\xe2\x9e!]\x16\xae{\xb8\x10?\xf9\xa5\xf9\x07\xfdBk'
        self.mylistenport = 4810
コード例 #40
0
 def setUp(self):
     """ override TestAsServer """
     TestAsServer.setUp(self)
     print >>sys.stderr,time.asctime(),'-', "test: Giving MyLaunchMany time to startup"
     time.sleep(5)
     print >>sys.stderr,time.asctime(),'-', "test: MyLaunchMany should have started up"
 
     # the metadata that we want to transfer
     self.tdef = TorrentDef()
     self.tdef.add_content(os.path.join(os.getcwd(), "API", "file.wmv"))
     self.tdef.set_tracker(self.session.get_internal_tracker_url())
     # we use a small piece length to obtain multiple pieces
     self.tdef.set_piece_length(1) 
     self.tdef.finalize()
     # self.tdef.save(os.path.join(self.session.get_state_dir(), "gen.torrent"))
     
     MagnetHelpers.__init__(self, self.tdef)
コード例 #41
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        # Let Tribler start downloading an non-functioning torrent, so
        # we can talk to a normal download engine.

        self.torrentfn = os.path.join('extend_hs_dir',
                                      'dummydata.merkle.torrent')
        tdef = TorrentDef.load(self.torrentfn)

        dscfg = self.setUpDownloadConfig()

        self.session.start_download(tdef, dscfg)

        # This is the infohash of the torrent in test/extend_hs_dir
        self.infohash = '\xccg\x07\xe2\x9e!]\x16\xae{\xb8\x10?\xf9\xa5\xf9\x07\xfdBk'
        self.mylistenport = 4810
コード例 #42
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)

        # Start our server side, to with Tribler will try to connect
        self.mylistenport = 4810
        self.myss = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.myss.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.myss.bind(('', self.mylistenport))
        self.myss.listen(1)
        
        # Must be changed in test/extend_hs_dir/dummydata.merkle.torrent as well
        self.mytrackerport = 4901
        self.myid = 'R410-----HgUyPu56789'
        self.mytracker = MyTracker(self.mytrackerport,self.myid,'127.0.0.1',self.mylistenport)
        self.mytracker.background_serve()

        self.myid2 = 'R410-----56789HuGyx0'
コード例 #43
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)

        self.setUpMyListenSockets()

        # Must be changed in test/extend_hs_dir/dummydata.merkle.torrent as well
        self.mytrackerport = 4901
        self.myid = 'R410-----HgUyPu56789'
        self.mytracker = MyTracker(self.mytrackerport, self.myid, '127.0.0.1',
                                   self.mylistenport)
        self.mytracker.background_serve()

        self.myid2 = 'R410-----56789HuGyx0'

        # Arno, 2009-12-15: Make sure coop downloads have their own destdir
        destdir = tempfile.mkdtemp()
        self.config.set_download_help_dir(destdir)
コード例 #44
0
ファイル: test_remote_torrent.py プロジェクト: vbit/IJS-stuff
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())

        # This is the infohash of the torrent in test/extend_hs_dir
        self.infohash = "\xccg\x07\xe2\x9e!]\x16\xae{\xb8\x10?\xf9\xa5\xf9\x07\xfdBk"
        self.torrentfile = os.path.join("extend_hs_dir", "dummydata.merkle.torrent")

        # TEMPARNO: retrieve this from Session
        self.torrent_db = TorrentDBHandler.getInstance()

        # Add two torrents that will match our query and one that shouldn't
        torrent = self.get_default_torrent("Hallo S01E10")
        ih = "b" * 20
        self.torrent_db.addTorrent(ih, torrent)
コード例 #45
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())  
        
        # This is the infohash of the torrent in test/extend_hs_dir
        self.infohash = '\xccg\x07\xe2\x9e!]\x16\xae{\xb8\x10?\xf9\xa5\xf9\x07\xfdBk'
        self.torrentfile = os.path.join('extend_hs_dir','dummydata.merkle.torrent')

        # Add us as friend, so he will accept the DOWNLOAD_HELP
        if False:  # TEMP
            friendsdb = FriendDBHandler.getInstance()
            friendsdb.addFriend(self.mypermid)
        else:
            self.session.set_overlay_request_policy(AllowAllRequestPolicy())
          
        self.session.set_download_states_callback(self.states_callback)
コード例 #46
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())

        # This is the infohash of the torrent in test/extend_hs_dir
        self.infohash = '\xccg\x07\xe2\x9e!]\x16\xae{\xb8\x10?\xf9\xa5\xf9\x07\xfdBk'
        self.torrentfile = os.path.join('extend_hs_dir',
                                        'dummydata.merkle.torrent')

        # TEMPARNO: retrieve this from Session
        self.torrent_db = TorrentDBHandler.getInstance()

        # Add two torrents that will match our query and one that shouldn't
        torrent = self.get_default_torrent('Hallo S01E10')
        ih = 'b' * 20
        self.torrent_db.addTorrent(ih, torrent)
コード例 #47
0
    def setUpPreSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPreSession(self)

        self.setUpMyListenSockets()
        
        # Must be changed in test/extend_hs_dir/proxyservice.test.torrent as well
        self.mytrackerport = 4901
        self.myid = 'R410-----HgUyPu56789'
        self.mytracker = MyTracker(self.mytrackerport,self.myid,'127.0.0.1',self.mylistenport)
        self.mytracker.background_serve()

        self.myid2 = 'R410-----56789HuGyx0' # used for the coordinator
        
        # Arno, 2009-12-15: Make sure coop downloads have their own destdir
        destdir = tempfile.mkdtemp()
        self.config.set_download_help_dir(destdir)
        
        # Set the proxyservice to full speed
        self.config.set_proxyservice_status(1) #PROXYSERVICE_ON=1
コード例 #48
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())  
        
        # This is the infohash of the torrent in test/extend_hs_dir
        self.infohash = '\xccg\x07\xe2\x9e!]\x16\xae{\xb8\x10?\xf9\xa5\xf9\x07\xfdBk'
        self.torrentfile = os.path.join('extend_hs_dir','dummydata.merkle.torrent')

        # Let Tribler start downloading an non-functioning torrent, so
        # we can talk to a normal download engine.
        
        tdef = TorrentDef.load(self.torrentfile)

        dscfg = DownloadStartupConfig()
        dscfg.set_dest_dir(self.config_path)
        
        self.session.start_download(tdef,dscfg)
コード例 #49
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())

        # This is the infohash of the torrent in test/extend_hs_dir
        self.infohash = '\xccg\x07\xe2\x9e!]\x16\xae{\xb8\x10?\xf9\xa5\xf9\x07\xfdBk'
        self.torrentfile = os.path.join('extend_hs_dir',
                                        'dummydata.merkle.torrent')

        # Add us as friend, so he will accept the DOWNLOAD_HELP
        if False:  # TEMP
            friendsdb = FriendDBHandler.getInstance()
            friendsdb.addFriend(self.mypermid)
        else:
            self.session.set_overlay_request_policy(AllowAllRequestPolicy())

        self.session.set_download_states_callback(self.states_callback)
コード例 #50
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der()) 

        # Create URL compat torrents and save in Torrent database.
        self.tdef1 = TorrentDef.load_from_url(P2PURL_SCHEME+'://127.2.3.42:7764/announce?SjaakCam.mpegts&k=MHowDQYJKoZIhvcNAQEBBQADaQAwZgJhAN0Khlp5ZhWC7VfLynCkKts71b8h8tZXH87PkDtJUTJaX_SS1Cddxkv63PRmKOvtAHhkTLSsWOZbSeHkOlPIq_FGg2aDLDJ05g3lQ-8mSmo05ff4SLqNUTShWO2CR2TPhQIBAw&l=HCAAAA&s=15&a=RSA&b=AAIAAA')
        self.torrentfn1 = os.path.join(self.session.get_torrent_collecting_dir(),"live.torrent")
        self.tdef1.save(self.torrentfn1)

        self.tdef2 = TorrentDef.load_from_url(P2PURL_SCHEME+'://127.1.0.10:6969/announce?trailer.mkv&r=TTgcifG0Ot7STCY2JL8SUOxROFo&l=AKK35A&s=15&b=AAFnGg')
        self.torrentfn2 = os.path.join(self.session.get_torrent_collecting_dir(),"vod.torrent")
        self.tdef2.save(self.torrentfn2)

        self.torrent_db = self.session.open_dbhandler(NTFY_TORRENTS)
        extra_info = {'status':'good'}
        self.torrent_db.addExternalTorrent(self.torrentfn1, source='',extra_info=extra_info)
        self.torrent_db.addExternalTorrent(self.torrentfn2, source='',extra_info=extra_info)
コード例 #51
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        #self.mypermid = str(self.my_keypair.pub().get_der())
        #self.hispermid = str(self.his_keypair.pub().get_der())
        
        self.torrent_db = self.session.open_dbhandler(NTFY_TORRENTS)
        try:
            # Add two torrents that will match our query and one that shouldn't
            self.bmetainfo1 = self.get_default_torrent('sumfilename1','Hallo S01E10')
            dbrec= self.torrent_db.addExternalTorrent('sumfilename1',metadata=self.bmetainfo1)
            self.infohash1 = dbrec['infohash']
            
            self.bmetainfo2 = self.get_default_torrent('sumfilename2','Hallo S02E01')
            dbrec = self.torrent_db.addExternalTorrent('sumfilename2',metadata=self.bmetainfo2)
            self.infohash2 = dbrec['infohash']
    
            self.bmetainfo3 = self.get_default_torrent('sumfilename3','Halo Demo')
            self.torrent_db.addExternalTorrent('sumfilename3',metadata=self.bmetainfo3)
        except:
            print_exc()
コード例 #52
0
    def setUpPostSession(self):
        """ override TestAsServer """
        TestAsServer.setUpPostSession(self)

        self.mypermid = str(self.my_keypair.pub().get_der())
        self.hispermid = str(self.his_keypair.pub().get_der())        
        self.myhash = sha(self.mypermid).digest()
        
        self.buddycast = BuddyCastFactory.getInstance(superpeer=True)
        self.buddycast.olthread_register(True)
        
#        arg0 = sys.argv[0].lower()
#        if arg0.endswith('.exe'):
#            installdir = os.path.abspath(os.path.dirname(sys.argv[0]))
#        else:
#           installdir = os.getcwd()          
#       self.utility = Utility(installdir)        

        
        # wait for buddycast to have completed on run cycle,
        # seems to create problems otherwise
        while not self.buddycast.ranonce:
            pass
コード例 #53
0
 def tearDown(self):
     TestAsServer.tearDown(self)
     self.session.close_dbhandler(self.torrent_db)
コード例 #54
0
 def setUpPreSession(self):
     """ override TestAsServer """
     TestAsServer.setUpPreSession(self)
コード例 #55
0
 def tearDown(self):
     """ override TestAsServer """
     print >> sys.stderr, "test: *** TEARDOWN"
     TestAsServer.tearDown(self)
     self.mytracker.shutdown()
     self.tearDownMyListenSockets()
コード例 #56
0
ファイル: test_g2g.py プロジェクト: smoothit/smoothit-client
 def setUp(self):
     """ override TestAsServer """
     TestAsServer.setUp(self)
     print >> sys.stderr, "test: Giving MyLaunchMany time to startup"
     time.sleep(3)
     print >> sys.stderr, "test: MyLaunchMany should have started up"