Exemple #1
0
 def refreshTracker(self):
     torrent = self.standardDetails.getData()
     if not torrent:
         return
     if DEBUG:
         print >>sys.stderr,'GUIUtility: refresh ' + repr(torrent.get('content_name', 'no_name'))
     if torrent:
         check = TorrentChecking(torrent['infohash'])
         check.start()
def run():
    print "start run"
    #    torrent_db = TorrentDBHandler.getInstance()
    #    key = ['infohash', 'torrent_name', 'torrent_dir', 'relevance', 'info',
    #                'num_owners', 'leecher', 'seeder', 'category']
    #    data = torrent_db.getRecommendedTorrents(key)
    #
    #    for idata in data[54:100]:
    #        trackerChecking(idata)
    for x in range(1000):
        t = TorrentChecking()
        t.start()
        sleep(2)
    def tearDown(self):
        self.torrentChecking.shutdown()
        TorrentChecking.delInstance()

        if SQLiteCacheDB.hasInstance():
            SQLiteCacheDB.getInstance().close_all()
            SQLiteCacheDB.delInstance()

        TorrentDBHandler.delInstance()
        MyPreferenceDBHandler.delInstance()
        NetworkBuzzDBHandler.delInstance()

        self.tearDownCleanup()
Exemple #4
0
    def tearDown(self):
        self.torrentChecking.shutdown()
        TorrentChecking.delInstance()

        if SQLiteCacheDB.hasInstance():
            SQLiteCacheDB.getInstance().close_all()
            SQLiteCacheDB.delInstance()

        TorrentDBHandler.delInstance()
        MyPreferenceDBHandler.delInstance()
        NetworkBuzzDBHandler.delInstance()

        self.tearDownCleanup()
def run():
    print "start run"
#    torrent_db = TorrentDBHandler.getInstance()
#    key = ['infohash', 'torrent_name', 'torrent_dir', 'relevance', 'info', 
#                'num_owners', 'leecher', 'seeder', 'category']
#    data = torrent_db.getRecommendedTorrents(key)
#
#    for idata in data[54:100]:
#        trackerChecking(idata)
    for x in range(1000):        
        t = TorrentChecking()
        t.start()
        sleep(2)
Exemple #6
0
    def setUp(self):
        self.setUpCleanup()

        config = {}
        config['state_dir'] = self.getStateDir()
        config['install_dir'] = '.'
        init_db(config)

        self.tdb = TorrentDBHandler.getInstance()
        self.tdb.torrent_dir = FILES_DIR
        self.tdb.mypref_db = MyPreferenceDBHandler.getInstance()
        self.tdb._nb = NetworkBuzzDBHandler.getInstance()

        self.torrentChecking = TorrentChecking()
        sleep(5)
Exemple #7
0
class TestTorrentChecking(AbstractServer):
    def setUp(self):
        self.setUpCleanup()

        config = {}
        config['state_dir'] = self.getStateDir()
        config['install_dir'] = '.'
        init_db(config)

        self.tdb = TorrentDBHandler.getInstance()
        self.tdb.torrent_dir = FILES_DIR
        self.tdb.mypref_db = MyPreferenceDBHandler.getInstance()
        self.tdb._nb = NetworkBuzzDBHandler.getInstance()

        self.torrentChecking = TorrentChecking()
        sleep(5)

    def test_torrent_checking(self):
        tdef = TorrentDef.load(
            os.path.join(BASE_DIR, "data",
                         "Pioneer.One.S01E06.720p.x264-VODO.torrent"))
        tdef.set_tracker("http://95.211.198.141:2710/announce")
        tdef.metainfo_valid = True

        self.tdb.addExternalTorrent(tdef)
        self.torrentChecking.addToQueue(tdef.get_infohash())
        sleep(30)

        id, num_leechers, num_seeders, last_check = self.tdb.getSwarmInfoByInfohash(
            tdef.get_infohash())
        assert num_leechers >= 0 or num_seeders >= 0, (num_leechers,
                                                       num_seeders)

    def tearDown(self):
        self.torrentChecking.shutdown()
        TorrentChecking.delInstance()

        if SQLiteCacheDB.hasInstance():
            SQLiteCacheDB.getInstance().close_all()
            SQLiteCacheDB.delInstance()

        TorrentDBHandler.delInstance()
        MyPreferenceDBHandler.delInstance()
        NetworkBuzzDBHandler.delInstance()

        self.tearDownCleanup()
class TestTorrentChecking(AbstractServer):

    def setUp(self):
        self.setUpCleanup()

        config = {}
        config['state_dir'] = self.getStateDir()
        config['install_dir'] = '.'
        init_db(config)

        self.tdb = TorrentDBHandler.getInstance()
        self.tdb.torrent_dir = FILES_DIR
        self.tdb.mypref_db = MyPreferenceDBHandler.getInstance()
        self.tdb._nb = NetworkBuzzDBHandler.getInstance()

        self.torrentChecking = TorrentChecking()
        sleep(5)

    def test_torrent_checking(self):
        tdef = TorrentDef.load(os.path.join(BASE_DIR, "data", "Pioneer.One.S01E06.720p.x264-VODO.torrent"))
        tdef.set_tracker("http://95.211.198.141:2710/announce")
        tdef.metainfo_valid = True

        self.tdb.addExternalTorrent(tdef)
        self.torrentChecking.addToQueue(tdef.get_infohash())
        sleep(30)

        id, num_leechers, num_seeders, last_check = self.tdb.getSwarmInfoByInfohash(tdef.get_infohash())
        assert num_leechers >= 0 or num_seeders >= 0, (num_leechers, num_seeders)

    def tearDown(self):
        self.torrentChecking.shutdown()
        TorrentChecking.delInstance()

        if SQLiteCacheDB.hasInstance():
            SQLiteCacheDB.getInstance().close_all()
            SQLiteCacheDB.delInstance()

        TorrentDBHandler.delInstance()
        MyPreferenceDBHandler.delInstance()
        NetworkBuzzDBHandler.delInstance()

        self.tearDownCleanup()
    def setUp(self):
        self.setUpCleanup()

        config = {}
        config['state_dir'] = self.getStateDir()
        config['install_dir'] = '.'
        init_db(config)

        self.tdb = TorrentDBHandler.getInstance()
        self.tdb.torrent_dir = FILES_DIR
        self.tdb.mypref_db = MyPreferenceDBHandler.getInstance()
        self.tdb._nb = NetworkBuzzDBHandler.getInstance()

        self.torrentChecking = TorrentChecking()
        sleep(5)
Exemple #10
0
    def init(self):
        config = self.session.sessconfig  # Should be safe at startup

        self.mainline_dht = None
        if config['mainline_dht']:
            from Tribler.Core.DecentralizedTracking import mainlineDHT
            try:
                self.mainline_dht = mainlineDHT.init(
                    ('127.0.0.1', config['mainline_dht_port']),
                    config['state_dir'], config['swiftdhtport'])
                self.upnp_ports.append((config['mainline_dht_port'], 'UDP'))
            except:
                print_exc()

        self.ltmgr = None
        if config['libtorrent']:
            from Tribler.Core.Libtorrent.LibtorrentMgr import LibtorrentMgr
            self.ltmgr = LibtorrentMgr(
                self.session, ignore_singleton=self.session.ignore_singleton)

        # add task for tracker checking
        self.torrent_checking = None
        if config['torrent_checking']:
            if config['mainline_dht']:
                # Create torrent-liveliness checker based on DHT
                from Tribler.Core.DecentralizedTracking.mainlineDHTChecker import mainlineDHTChecker

                c = mainlineDHTChecker.getInstance()
                c.register(self.mainline_dht)

            try:
                from Tribler.TrackerChecking.TorrentChecking import TorrentChecking
                self.torrent_checking_period = config[
                    'torrent_checking_period']
                self.torrent_checking = TorrentChecking.getInstance(
                    self.torrent_checking_period)
                self.run_torrent_check()
            except:
                print_exc

        if self.rtorrent_handler:
            self.rtorrent_handler.register(
                self.dispersy, self.database_thread, self.session,
                int(config['torrent_collecting_max_torrents']))

        self.initComplete = True
Exemple #11
0
    def init(self):
        config = self.session.sessconfig  # Should be safe at startup

        self.mainline_dht = None
        if config['mainline_dht']:
            from Tribler.Core.DecentralizedTracking import mainlineDHT
            try:
                self.mainline_dht = mainlineDHT.init(('127.0.0.1', config['mainline_dht_port']), config['state_dir'], config['swiftdhtport'])
                self.upnp_ports.append((config['mainline_dht_port'], 'UDP'))
            except:
                print_exc()

        self.ltmgr = None
        if config['libtorrent']:
            from Tribler.Core.Libtorrent.LibtorrentMgr import LibtorrentMgr
            self.ltmgr = LibtorrentMgr(self.session, ignore_singleton=self.session.ignore_singleton)

        # add task for tracker checking
        self.torrent_checking = None
        if config['torrent_checking']:
            if config['mainline_dht']:
                # Create torrent-liveliness checker based on DHT
                from Tribler.Core.DecentralizedTracking.mainlineDHTChecker import mainlineDHTChecker

                c = mainlineDHTChecker.getInstance()
                c.register(self.mainline_dht)

            try:
                from Tribler.TrackerChecking.TorrentChecking import TorrentChecking
                self.torrent_checking_period = config['torrent_checking_period']
                self.torrent_checking = TorrentChecking.getInstance(self.torrent_checking_period)
                self.run_torrent_check()
            except:
                print_exc

        if self.rtorrent_handler:
            self.rtorrent_handler.register(self.dispersy, self.database_thread, self.session, int(config['torrent_collecting_max_torrents']))

        self.initComplete = True
Exemple #12
0
 def refreshTrackerStatus(self, torrent):
     "Upon the reception of a new discovered torrent, directly check its tracker"
     if DEBUG:
         print >> sys.stderr, "metadata: checking tracker status of new torrent"
     t = TorrentChecking.getInstance()
     t.addToQueue(torrent['infohash'])
 def refreshTrackerStatus(self, torrent):
     "Upon the reception of a new discovered torrent, directly check its tracker"
     if DEBUG:
         print >> sys.stderr, time.asctime(),'-', "metadata: checking tracker status of new torrent"
     check = TorrentChecking(torrent['infohash'])
     check.start()
 def refreshTrackerStatus(self, torrent):
     "Upon the reception of a new discovered torrent, directly check its tracker"
     if DEBUG:
         print >> sys.stderr, "metadata: checking tracker status of new torrent"
     t = TorrentChecking.getInstance()
     t.addToQueue(torrent['infohash'])
Exemple #15
0
 def refreshTrackerStatus(self, torrent):
     "Upon the reception of a new discovered torrent, directly check its tracker"
     if DEBUG:
         print >> sys.stderr, "metadata: checking tracker status of new torrent"
     check = TorrentChecking(torrent['infohash'])
     check.start()