Exemplo n.º 1
0
 def __init__(self, master, integrate_with_tribler = True):
     super(SearchCommunity, self).__init__(master)
     
     self.integrate_with_tribler = integrate_with_tribler
     self.taste_buddies = []
     
     if self.integrate_with_tribler:
         from Tribler.Core.CacheDB.SqliteCacheDBHandler import ChannelCastDBHandler, TorrentDBHandler, MyPreferenceDBHandler
         from Tribler.Core.CacheDB.Notifier import Notifier 
     
         # tribler channelcast database
         self._channelcast_db = ChannelCastDBHandler.getInstance()
         self._torrent_db = TorrentDBHandler.getInstance()
         self._mypref_db = MyPreferenceDBHandler.getInstance()
         self._notifier = Notifier.getInstance()
         
         # torrent collecting
         self._rtorrent_handler = RemoteTorrentHandler.getInstance()
     else:
         self._channelcast_db = ChannelCastDBStub(self._dispersy)
         self._torrent_db = None
         self._mypref_db = None
         self._notifier = None
         
     self.taste_bloom_filter = None
     self.taste_bloom_filter_key = None
     
     self.dispersy.callback.register(self.create_torrent_collect_requests, delay = CANDIDATE_WALK_LIFETIME)
Exemplo n.º 2
0
 def __init__(self, master, integrate_with_tribler = True):
     super(SearchCommunity, self).__init__(master)
     
     self.integrate_with_tribler = integrate_with_tribler
     self.taste_buddies = []
     #To always connect to a peer uncomment/modify the following line
     #self.taste_buddies.append([1, time(), Candidate(("127.0.0.1", 1234), False))
     
     if self.integrate_with_tribler:
         from Tribler.Core.CacheDB.SqliteCacheDBHandler import ChannelCastDBHandler, TorrentDBHandler, MyPreferenceDBHandler
         from Tribler.Core.CacheDB.Notifier import Notifier 
     
         # tribler channelcast database
         self._channelcast_db = ChannelCastDBHandler.getInstance()
         self._torrent_db = TorrentDBHandler.getInstance()
         self._mypref_db = MyPreferenceDBHandler.getInstance()
         self._notifier = Notifier.getInstance()
         
         # torrent collecting
         self._rtorrent_handler = RemoteTorrentHandler.getInstance()
     else:
         self._channelcast_db = ChannelCastDBStub(self._dispersy)
         self._torrent_db = None
         self._mypref_db = None
         self._notifier = None
         
     self.taste_bloom_filter = None
     self.taste_bloom_filter_key = None
     
     self.torrent_cache = None
     
     self.dispersy.callback.register(self.create_torrent_collect_requests, delay = CANDIDATE_WALK_LIFETIME)
     self.dispersy.callback.register(self.fast_walker)
Exemplo n.º 3
0
    def __init__(self, dispersy, master, integrate_with_tribler=True):
        super(SearchCommunity, self).__init__(dispersy, master)

        self.integrate_with_tribler = integrate_with_tribler
        self.taste_buddies = []
        # To always connect to a peer uncomment/modify the following line
        # self.taste_buddies.append([1, time(), Candidate(("127.0.0.1", 1234), False))

        if self.integrate_with_tribler:
            from Tribler.Core.CacheDB.SqliteCacheDBHandler import ChannelCastDBHandler, TorrentDBHandler, MyPreferenceDBHandler
            from Tribler.Core.CacheDB.Notifier import Notifier

            # tribler channelcast database
            self._channelcast_db = ChannelCastDBHandler.getInstance()
            self._torrent_db = TorrentDBHandler.getInstance()
            self._mypref_db = MyPreferenceDBHandler.getInstance()
            self._notifier = Notifier.getInstance()

            # torrent collecting
            self._rtorrent_handler = RemoteTorrentHandler.getInstance()
        else:
            self._channelcast_db = ChannelCastDBStub(self._dispersy)
            self._torrent_db = None
            self._mypref_db = None
            self._notifier = None

        self.taste_bloom_filter = None
        self.taste_bloom_filter_key = None

        self.torrent_cache = None

        self.dispersy.callback.register(self.create_torrent_collect_requests,
                                        delay=CANDIDATE_WALK_LIFETIME)
        self.dispersy.callback.register(self.fast_walker)
Exemplo n.º 4
0
    def __init__(self, master, integrate_with_tribler=True):
        super(SearchCommunity, self).__init__(master)

        self.integrate_with_tribler = integrate_with_tribler
        self.taste_buddies = []

        if self.integrate_with_tribler:
            from Tribler.Core.CacheDB.SqliteCacheDBHandler import ChannelCastDBHandler, TorrentDBHandler, MyPreferenceDBHandler
            from Tribler.Core.CacheDB.Notifier import Notifier

            # tribler channelcast database
            self._channelcast_db = ChannelCastDBHandler.getInstance()
            self._torrent_db = TorrentDBHandler.getInstance()
            self._mypref_db = MyPreferenceDBHandler.getInstance()
            self._notifier = Notifier.getInstance()

            # torrent collecting
            self._rtorrent_handler = RemoteTorrentHandler.getInstance()
        else:
            self._channelcast_db = ChannelCastDBStub(self._dispersy)
            self._torrent_db = None
            self._mypref_db = None
            self._notifier = None

        self.taste_bloom_filter = None
        self.taste_bloom_filter_key = None

        self.dispersy.callback.register(self.create_torrent_collect_requests,
                                        delay=CANDIDATE_WALK_LIFETIME)
Exemplo n.º 5
0
    def set_torrent_collecting_max_torrents(self, value):
        self.sesslock.acquire()
        try:
            SessionConfigInterface.set_torrent_collecting_max_torrents(self, value)

            from Tribler.Core.RemoteTorrentHandler import RemoteTorrentHandler
            rth = RemoteTorrentHandler.getInstance()
            rth.set_max_num_torrents(value)
        finally:
            self.sesslock.release()
Exemplo n.º 6
0
Arquivo: home.py Projeto: duy/tribler
    def __init__(self, parent):
        HomePanel.__init__(self, parent, 'Network info' , SEPARATOR_GREY, (0, 1))

        self.torrentdb = TorrentDBHandler.getInstance()
        self.channelcastdb = ChannelCastDBHandler.getInstance()
        self.remotetorrenthandler = RemoteTorrentHandler.getInstance()

        self.timer = None

        session = Session.get_instance()
        session.add_observer(self.OnNotify, NTFY_TORRENTS, [NTFY_INSERT])
        self.UpdateStats()
    def __init__(self, parent):
        HomePanel.__init__(self, parent, 'Network info', SEPARATOR_GREY,
                           (0, 1))

        self.torrentdb = TorrentDBHandler.getInstance()
        self.channelcastdb = ChannelCastDBHandler.getInstance()
        self.remotetorrenthandler = RemoteTorrentHandler.getInstance()

        self.timer = None

        session = Session.get_instance()
        session.add_observer(self.OnNotify, NTFY_TORRENTS, [NTFY_INSERT])
        self.UpdateStats()
Exemplo n.º 8
0
    def __init__(self, parent):
        HomePanel.__init__(self, parent, 'Network info', LIST_BLUE)

        self.torrentdb = TorrentDBHandler.getInstance()
        self.channelcastdb = ChannelCastDBHandler.getInstance()
        self.remotetorrenthandler = RemoteTorrentHandler.getInstance()
        self.remotequerymsghandler = RemoteQueryMsgHandler.getInstance()
        self.incompleteCounter = IncompleteCounter.getInstance()

        self.timer = None

        session = Session.get_instance()
        session.add_observer(self.OnNotify, NTFY_TORRENTS, [NTFY_INSERT])
        self.UpdateStats()
Exemplo n.º 9
0
    def __init__(self, parent):
        HomePanel.__init__(self, parent, 'Network info' , LIST_BLUE)

        self.torrentdb = TorrentDBHandler.getInstance()
        self.channelcastdb = ChannelCastDBHandler.getInstance()
        self.remotetorrenthandler = RemoteTorrentHandler.getInstance()
        self.remotequerymsghandler = RemoteQueryMsgHandler.getInstance()
        self.incompleteCounter = IncompleteCounter.getInstance()

        self.timer = None

        session = Session.get_instance()
        session.add_observer(self.OnNotify, NTFY_TORRENTS, [NTFY_INSERT])
        self.UpdateStats()
Exemplo n.º 10
0
 def download_torrentfile(self, infohash = None, roothash = None, usercallback = None, prio = 0):
     """ Try to download the torrentfile without a known source.
     A possible source could be the DHT.
     If the torrent is succesfully 
     received, the usercallback method is called with the infohash as first
     and the contents of the torrentfile (bencoded dict) as second parameter.
     If the torrent could not be obtained, the callback is not called.
     The torrent will have been added to the TorrentDBHandler (if enabled)
     at the time of the call.
     @param infohash The infohash of the torrent.
     @param usercallback A function adhering to the above spec.
     """
     from Tribler.Core.RemoteTorrentHandler import RemoteTorrentHandler
         
     rtorrent_handler = RemoteTorrentHandler.getInstance()
     rtorrent_handler.download_torrent(None,infohash,roothash,usercallback,prio)
Exemplo n.º 11
0
    def download_torrentfile(self, infohash=None, roothash=None, usercallback=None, prio=0):
        """ Try to download the torrentfile without a known source.
        A possible source could be the DHT.
        If the torrent is succesfully
        received, the usercallback method is called with the infohash as first
        and the contents of the torrentfile (bencoded dict) as second parameter.
        If the torrent could not be obtained, the callback is not called.
        The torrent will have been added to the TorrentDBHandler (if enabled)
        at the time of the call.
        @param infohash The infohash of the torrent.
        @param usercallback A function adhering to the above spec.
        """
        from Tribler.Core.RemoteTorrentHandler import RemoteTorrentHandler

        rtorrent_handler = RemoteTorrentHandler.getInstance()
        rtorrent_handler.download_torrent(None, infohash, roothash, usercallback, prio)
Exemplo n.º 12
0
    def register(self, session, defaultkey):
        if not self.isRegistered:
            self.session = session
            self.defaultkey = defaultkey
            self.remote_th = RemoteTorrentHandler.getInstance()

            dirname = self.getdir()
            if not os.path.exists(dirname):
                os.makedirs(dirname)

            # read any rss feeds that are currently outstanding
            self.readfile()

            self.isRegistered = True
        elif DEBUG:
            print >> sys.stderr, "RssParser is already registered, ignoring"
Exemplo n.º 13
0
    def register(self, session, defaultkey):
        if not self.isRegistered:
            self.session = session
            self.defaultkey = defaultkey
            self.remote_th = RemoteTorrentHandler.getInstance()

            dirname = self.getdir()
            if not os.path.exists(dirname):
                os.makedirs(dirname)

            # read any rss feeds that are currently outstanding
            self.readfile()

            self.isRegistered = True
        elif DEBUG:
            print >> sys.stderr, "RssParser is already registered, ignoring"
Exemplo n.º 14
0
 def download_torrentmessages_from_peer(self, candidate, infohashes, usercallback, prio = 0):
     """ Ask the designated peer to send us the torrentfile for the torrent
     identified by the passed infohash. If the torrent is succesfully 
     received, the usercallback method is called with the infohash as first
     and the contents of the torrentfile (bencoded dict) as second parameter.
     If the torrent could not be obtained, the callback is not called.
     The torrent will have been added to the TorrentDBHandler (if enabled)
     at the time of the call.
     
     @param permid The PermID of the peer to query.
     @param infohash The infohash of the torrent.
     @param usercallback A function adhering to the above spec.
     """
     from Tribler.Core.RemoteTorrentHandler import RemoteTorrentHandler
         
     rtorrent_handler = RemoteTorrentHandler.getInstance()
     rtorrent_handler.download_torrentmessages(candidate,infohashes,usercallback,prio)
Exemplo n.º 15
0
    def download_torrentmessages_from_peer(self, candidate, infohashes, usercallback, prio=0):
        """ Ask the designated peer to send us the torrentfile for the torrent
        identified by the passed infohash. If the torrent is succesfully
        received, the usercallback method is called with the infohash as first
        and the contents of the torrentfile (bencoded dict) as second parameter.
        If the torrent could not be obtained, the callback is not called.
        The torrent will have been added to the TorrentDBHandler (if enabled)
        at the time of the call.

        @param permid The PermID of the peer to query.
        @param infohash The infohash of the torrent.
        @param usercallback A function adhering to the above spec.
        """
        from Tribler.Core.RemoteTorrentHandler import RemoteTorrentHandler

        rtorrent_handler = RemoteTorrentHandler.getInstance()
        rtorrent_handler.download_torrentmessages(candidate, infohashes, usercallback, prio)