コード例 #1
0
ファイル: GuiDBTuples.py プロジェクト: Antiade/tribler
            def do_dispersy():
                from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

                self._logger.debug("Channel: fetching getChannelStateByCID from DB %s", self)

                searchManager = ChannelManager.getInstance()
                result = searchManager.getChannelStateByCID(self.dispersy_cid)
                return result
コード例 #2
0
ファイル: GuiDBTuples.py プロジェクト: Antiade/tribler
    def torrent(self):
        if self.channeltorrent_id:
            from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

            self._logger.debug("Marking: fetching getTorrentFromChannelTorrentId from DB %s", self)

            searchManager = ChannelManager.getInstance()
            return searchManager.getTorrentFromChannelTorrentId(None, self.channeltorrent_id, False)
コード例 #3
0
ファイル: GuiDBTuples.py プロジェクト: brussee/tribler
            def do_dispersy():
                from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

                self._logger.debug(
                    "Channel: fetching getChannelStateByCID from DB %s", self)

                searchManager = ChannelManager.getInstance()
                result = searchManager.getChannelStateByCID(self.dispersy_cid)
                return result
コード例 #4
0
 def torrent(self):
     if self._torrent is not None:
         return self._torrent
     
     if self.channeltorrent_id:
         from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager
         
         searchManager = ChannelManager.getInstance()
         return searchManager.getTorrentFromChannelTorrentId(self.channel, self.channeltorrent_id)
コード例 #5
0
ファイル: GuiDBTuples.py プロジェクト: Anbcorp/tribler
    def torrent(self):
        if self.channeltorrent_id:
            from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

            if DEBUGDB:
                print >> sys.stderr, "Marking: fetching getTorrentFromChannelTorrentId from DB", self

            searchManager = ChannelManager.getInstance()
            return searchManager.getTorrentFromChannelTorrentId(None, self.channeltorrent_id, False)
コード例 #6
0
ファイル: GuiDBTuples.py プロジェクト: ebcabaybay/swiftarm
    def torrent(self):
        if self.channeltorrent_id:
            from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

            if DEBUGDB:
                print >> sys.stderr, "Marking: fetching getTorrentFromChannelTorrentId from DB", self

            searchManager = ChannelManager.getInstance()
            return searchManager.getTorrentFromChannelTorrentId(
                None, self.channeltorrent_id)
コード例 #7
0
 def getState(self):
     if self.isDispersy():
         from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager
         
         searchManager = ChannelManager.getInstance()
         result = searchManager.getChannelStateByCID(self.dispersy_cid)
         if result:
             return result 
     
     return ChannelCommunity.CHANNEL_CLOSED, self.isMyChannel()
コード例 #8
0
 def register(self):
     self.torrentsearch_manager = TorrentManager.getInstance(self)
     self.channelsearch_manager = ChannelManager.getInstance()
     self.library_manager = LibraryManager.getInstance(self)
     self.torrentstate_manager = TorrentStateManager.getInstance(self)
     
     self.torrentsearch_manager.connect(self.utility.session, self.library_manager, self.channelsearch_manager)
     self.channelsearch_manager.connect(self.utility.session, self.torrentsearch_manager)
     self.library_manager.connect(self.utility.session, self.torrentsearch_manager)
     self.torrentstate_manager.connect(self.torrentsearch_manager, self.library_manager, self.channelsearch_manager)
コード例 #9
0
ファイル: GuiDBTuples.py プロジェクト: zzmjohn/tribler
 def loadPopularTorrentNames(self, num_torrents, force_refresh=False):
     if not self.popular_torrents or force_refresh:
         from Tribler.Main.vwxGUI.GuiUtility import GUIUtility
         from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager
         results = ChannelManager.getInstance(
         ).getMostPopularTorrentsFromChannel(
             self.id, ['Torrent.Name'],
             family_filter=GUIUtility.getInstance().getFamilyFilter(),
             limit=num_torrents)
         self.popular_torrents = [result[0] for result in results]
コード例 #10
0
ファイル: GuiDBTuples.py プロジェクト: brussee/tribler
    def torrent(self):
        if self.channeltorrent_id:
            from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

            self._logger.debug(
                "Marking: fetching getTorrentFromChannelTorrentId from DB %s",
                self)

            searchManager = ChannelManager.getInstance()
            return searchManager.getTorrentFromChannelTorrentId(
                None, self.channeltorrent_id, False)
コード例 #11
0
 def torrent(self):
     if self._torrent is not None:
         return self._torrent
     
     if self.channeltorrent_id:
         from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager
         
         if DEBUGDB:
             print >> sys.stderr, "Comment: fetching getTorrentFromChannelTorrentId from DB", self
         
         searchManager = ChannelManager.getInstance()
         return searchManager.getTorrentFromChannelTorrentId(self.channel, self.channeltorrent_id)
コード例 #12
0
ファイル: GuiDBTuples.py プロジェクト: ebcabaybay/swiftarm
    def getState(self):
        if self.isDispersy():
            from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

            if DEBUGDB:
                print >> sys.stderr, "Channel: fetching getChannelStateByCID from DB", self

            searchManager = ChannelManager.getInstance()
            result = searchManager.getChannelStateByCID(self.dispersy_cid)
            if result:
                return result

        return ChannelCommunity.CHANNEL_CLOSED, self.isMyChannel()
コード例 #13
0
ファイル: GuiDBTuples.py プロジェクト: Anbcorp/tribler
    def getState(self):
        if self.isDispersy():
            from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

            if DEBUGDB:
                print >> sys.stderr, "Channel: fetching getChannelStateByCID from DB", self

            searchManager = ChannelManager.getInstance()
            result = searchManager.getChannelStateByCID(self.dispersy_cid)
            if result:
                return result

        return ChannelCommunity.CHANNEL_CLOSED, self.isMyChannel()
コード例 #14
0
ファイル: GuiDBTuples.py プロジェクト: zzmjohn/tribler
    def torrent(self):
        if self._torrent is not None:
            return self._torrent

        if self.channeltorrent_id:
            from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

            if DEBUGDB:
                print >> sys.stderr, "Comment: fetching getTorrentFromChannelTorrentId from DB", self

            searchManager = ChannelManager.getInstance()
            return searchManager.getTorrentFromChannelTorrentId(
                self.channel, self.channeltorrent_id, False)
コード例 #15
0
 def extended_description(self):
     if self.description:
         return self.description
     
     from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager
     
     #No description, get swarmnames
     searchManager = ChannelManager.getInstance()
     _,_, torrents =  searchManager.getTorrentsFromPlaylist(self, limit = 3)
     names = [torrent.name for torrent in torrents]
     if len(names) > 0:
         return "Contents: '"+"'    '".join(names)+"'"
     else:
         return 'This playlist is currently empty, drag and drop any .torrent to add it to this playlist.'
コード例 #16
0
ファイル: GuiUtility.py プロジェクト: duy/tribler
 def register(self):
     if not self.registered:
         self.registered = True
         
         self.torrentsearch_manager = TorrentManager.getInstance(self)
         self.channelsearch_manager = ChannelManager.getInstance()
         self.library_manager = LibraryManager.getInstance(self)
         self.torrentstate_manager = TorrentStateManager.getInstance(self)
         
         self.torrentsearch_manager.connect(self.utility.session, self.library_manager, self.channelsearch_manager)
         self.channelsearch_manager.connect(self.utility.session, self.library_manager, self.torrentsearch_manager)
         self.library_manager.connect(self.utility.session, self.torrentsearch_manager, self.channelsearch_manager)
         self.torrentstate_manager.connect(self.torrentsearch_manager, self.library_manager, self.channelsearch_manager)
     else:
         raise RuntimeError('GuiUtility is already registered')
コード例 #17
0
ファイル: GuiUtility.py プロジェクト: zzmjohn/tribler
    def register(self):
        if not self.registered:
            self.registered = True

            self.torrentsearch_manager = TorrentManager.getInstance(self)
            self.channelsearch_manager = ChannelManager.getInstance()
            self.library_manager = LibraryManager.getInstance(self)
            self.torrentstate_manager = TorrentStateManager.getInstance(self)

            self.torrentsearch_manager.connect(self.utility.session, self.library_manager, self.channelsearch_manager)
            self.channelsearch_manager.connect(self.utility.session, self.library_manager, self.torrentsearch_manager)
            self.library_manager.connect(self.utility.session, self.torrentsearch_manager, self.channelsearch_manager)
            self.torrentstate_manager.connect(self.torrentsearch_manager, self.library_manager, self.channelsearch_manager)
        else:
            raise RuntimeError('GuiUtility is already registered')
コード例 #18
0
    def register(self):
        self.torrentsearch_manager = TorrentManager.getInstance(self)
        self.channelsearch_manager = ChannelManager.getInstance()
        self.library_manager = LibraryManager.getInstance(self)
        self.torrentstate_manager = TorrentStateManager.getInstance(self)

        self.torrentsearch_manager.connect(self.utility.session,
                                           self.library_manager,
                                           self.channelsearch_manager)
        self.channelsearch_manager.connect(self.utility.session,
                                           self.torrentsearch_manager)
        self.library_manager.connect(self.utility.session,
                                     self.torrentsearch_manager,
                                     self.channelsearch_manager)
        self.torrentstate_manager.connect(self.torrentsearch_manager,
                                          self.library_manager,
                                          self.channelsearch_manager)
コード例 #19
0
ファイル: GuiDBTuples.py プロジェクト: ebcabaybay/swiftarm
    def extended_description(self):
        if self.description:
            return self.description

        from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

        #No description, get swarmnames
        searchManager = ChannelManager.getInstance()
        _, _, torrents = searchManager.getTorrentsFromPlaylist(self, limit=3)
        names = [torrent.name for torrent in torrents]
        if len(names) > 0:
            return "Contents: '" + "'    '".join(names) + "'"
        elif self.channel.isOpen():
            return 'This playlist is currently empty, drag and drop any .torrent to add it to this playlist.'
        elif self.channel.isMyChannel():
            return 'This playlist is currently empty, you are the only one who can add torrents to it.'
        return 'This playlist is currently empty, the channel owner has restricted anyone but himself to add torrents to it.'
コード例 #20
0
ファイル: GuiDBTuples.py プロジェクト: Anbcorp/tribler
    def extended_description(self):
        if self.description:
            return self.description

        from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager

        # No description, get swarmnames
        searchManager = ChannelManager.getInstance()
        _, _, torrents = searchManager.getTorrentsFromPlaylist(self, limit=3)
        names = [torrent.name for torrent in torrents]
        if len(names) > 0:
            return "Contents: '" + "'    '".join(names) +"'"
        elif self.channel.isOpen():
            return 'This playlist is currently empty, drag and drop any .torrent to add it to this playlist.'
        elif self.channel.isMyChannel():
            return 'This playlist is currently empty, you are the only one who can add torrents to it.'
        return 'This playlist is currently empty, the channel owner has restricted anyone but himself to add torrents to it.'
def dispersy_started(session, opt):
    myPermid = permid_for_user(session.get_permid())
    print >> sys.stderr, "permid: ", myPermid

    from Tribler.Main.vwxGUI.SearchGridManager import TorrentManager, LibraryManager, ChannelManager
    torrentManager = TorrentManager(None)
    libraryManager = LibraryManager(None)
    channelManager = ChannelManager()

    torrentManager.connect(session, libraryManager, channelManager)
    channelManager.connect(session, libraryManager, torrentManager)
    libraryManager.connect(session, torrentManager, channelManager)

    myChannelName = opt.channelname or opt.nickname or 'MetadataInjector-Channel'
    myChannelName = unicode(myChannelName)

    createdNewChannel = False
    myChannelId = channelManager.channelcast_db.getMyChannelId()
    if not myChannelId:
        print >> sys.stderr, "creating a new channel"
        channelManager.createChannel(myChannelName, u'')
        createdNewChannel = True

    else:
        print >> sys.stderr, "reusing previously created channel"
        myChannel = channelManager.getChannel(myChannelId)
        if myChannel.name != myChannelName:
            print >> sys.stderr, "renaming channel to", myChannelName
            channelManager.modifyChannel(myChannelId, {'name': myChannelName})

    #use dispersythread, this way we know our channel has been created
    @forceDispersyThread
    def createTorrentFeed():
        myChannelId = channelManager.channelcast_db.getMyChannelId()

        torrentfeed = RssParser.getInstance()
        torrentfeed.register(session, myChannelId)
        torrentfeed.addCallback(myChannelId,
                                channelManager.createTorrentFromDef)

        for rss in opt.rss.split(";"):
            torrentfeed.addURL(rss, myChannelId)

    if opt.rss:
        createTorrentFeed()

    #same here, using dispersythread to make sure channel has been created
    @forceDispersyThread
    def createDirFeed():
        myChannelId = channelManager.channelcast_db.getMyChannelId()

        def on_torrent_callback(dirpath, infohash, torrent_data):
            torrentdef = TorrentDef.load_from_dict(torrent_data)
            channelsearch_manager.createTorrentFromDef(myChannelId, torrentdef)

            #save torrent to collectedtorrents
            filename = torrentManager.getCollectedFilenameFromDef(torrentdef)
            if not os.path.isfile(filename):
                torrentdef.save(filename)

        dirfeed = DirectoryFeedThread.getInstance()
        for dirpath in opt.dir.split(";"):
            dirfeed.addDir(dirpath, callback=on_torrent_callback)

    if opt.dir:
        createDirFeed()

    #same here, using dispersythread to make sure channel has been created
    @forceDispersyThread
    def createFileFeed():
        myChannelId = channelManager.channelcast_db.getMyChannelId()
        community = channelManager._disp_get_community_from_channel_id(
            myChannelId)

        print >> sys.stderr, "Using community:", community._cid.encode('HEX')

        items = json.load(open(opt.file, 'rb'))
        for item in items:
            try:
                infohash = sha1(item['name']).digest()
            except:
                infohash = sha1(str(random.randint(0, 1000000))).digest()
            message = community._disp_create_torrent(infohash,
                                                     long(time.time()),
                                                     unicode(item['name']),
                                                     ((u'fake.file', 10), ),
                                                     tuple(),
                                                     update=False,
                                                     forward=False)

            print >> sys.stderr, "Created a new torrent"

            latest_review = None
            for modification in item['modifications']:
                reviewmessage = community._disp_create_modification(
                    'description',
                    unicode(modification['text']),
                    long(time.time()),
                    message,
                    latest_review,
                    update=False,
                    forward=False)

                print >> sys.stderr, "Created a new modification"

                if modification['revert']:
                    community._disp_create_moderation('reverted',
                                                      long(time.time()),
                                                      0,
                                                      reviewmessage.packet_id,
                                                      update=False,
                                                      forward=False)

                    print >> sys.stderr, "Reverted the last modification"
                else:
                    latest_review = reviewmessage

    if opt.file and createdNewChannel:
        createFileFeed()
コード例 #22
0
ファイル: metadata-injector.py プロジェクト: Anbcorp/tribler
def dispersy_started(session, opt):
    myPermid = permid_for_user(session.get_permid())
    print >> sys.stderr, "permid: ", myPermid

    from Tribler.Main.vwxGUI.SearchGridManager import TorrentManager, LibraryManager, ChannelManager
    torrentManager = TorrentManager(None)
    libraryManager = LibraryManager(None)
    channelManager = ChannelManager()

    torrentManager.connect(session, libraryManager, channelManager)
    channelManager.connect(session, libraryManager, torrentManager)
    libraryManager.connect(session, torrentManager, channelManager)

    myChannelName = opt.channelname or opt.nickname or 'MetadataInjector-Channel'
    myChannelName = unicode(myChannelName)

    createdNewChannel = False
    myChannelId = channelManager.channelcast_db.getMyChannelId()
    if not myChannelId:
        print >> sys.stderr, "creating a new channel"
        channelManager.createChannel(myChannelName, u'')
        createdNewChannel = True

    else:
        print >> sys.stderr, "reusing previously created channel"
        myChannel = channelManager.getChannel(myChannelId)
        if myChannel.name != myChannelName:
            print >> sys.stderr, "renaming channel to", myChannelName
            channelManager.modifyChannel(myChannelId, {'name': myChannelName})

    # use dispersythread, this way we know our channel has been created
    @forceDispersyThread
    def createTorrentFeed():
        myChannelId = channelManager.channelcast_db.getMyChannelId()

        torrentfeed = RssParser.getInstance()
        torrentfeed.register(session, myChannelId)
        torrentfeed.addCallback(myChannelId, channelManager.createTorrentFromDef)

        for rss in opt.rss.split(";"):
            torrentfeed.addURL(rss, myChannelId)

    if opt.rss:
        createTorrentFeed()

    # same here, using dispersythread to make sure channel has been created
    @forceDispersyThread
    def createDirFeed():
        myChannelId = channelManager.channelcast_db.getMyChannelId()

        def on_torrent_callback(dirpath, infohash, torrent_data):
            torrentdef = TorrentDef.load_from_dict(torrent_data)
            channelsearch_manager.createTorrentFromDef(myChannelId, torrentdef)

            # save torrent to collectedtorrents
            filename = torrentManager.getCollectedFilenameFromDef(torrentdef)
            if not os.path.isfile(filename):
                torrentdef.save(filename)

        dirfeed = DirectoryFeedThread.getInstance()
        for dirpath in opt.dir.split(";"):
            dirfeed.addDir(dirpath, callback=on_torrent_callback)

    if opt.dir:
        createDirFeed()

    # same here, using dispersythread to make sure channel has been created
    @forceDispersyThread
    def createFileFeed():
        myChannelId = channelManager.channelcast_db.getMyChannelId()
        community = channelManager._disp_get_community_from_channel_id(myChannelId)

        print >> sys.stderr, "Using community:", community._cid.encode('HEX')

        items = json.load(open(opt.file, 'rb'))
        for item in items:
            try:
                infohash = sha1(item['name']).digest()
            except:
                infohash = sha1(str(random.randint(0, 1000000))).digest()
            message = community._disp_create_torrent(infohash, long(time.time()), unicode(item['name']), ((u'fake.file', 10),), tuple(), update=False, forward=False)

            print >> sys.stderr, "Created a new torrent"

            latest_review = None
            for modification in item['modifications']:
                reviewmessage = community._disp_create_modification('description', unicode(modification['text']), long(time.time()), message, latest_review, update=False, forward=False)

                print >> sys.stderr, "Created a new modification"

                if modification['revert']:
                    community._disp_create_moderation('reverted', long(time.time()), 0, reviewmessage.packet_id, update=False, forward=False)

                    print >> sys.stderr, "Reverted the last modification"
                else:
                    latest_review = reviewmessage

    if opt.file and createdNewChannel:
        createFileFeed()
コード例 #23
0
ファイル: GuiDBTuples.py プロジェクト: Anbcorp/tribler
 def loadPopularTorrentNames(self, num_torrents, force_refresh=False):
     if not self.popular_torrents or force_refresh:
         from Tribler.Main.vwxGUI.GuiUtility import GUIUtility
         from Tribler.Main.vwxGUI.SearchGridManager import ChannelManager
         results = ChannelManager.getInstance().getMostPopularTorrentsFromChannel(self.id, ['Torrent.Name'], family_filter=GUIUtility.getInstance().getFamilyFilter(), limit= num_torrents)
         self.popular_torrents = [result[0] for result in results]
コード例 #24
0
def dispersy_started(session, opt):
    myPermid = permid_for_user(session.get_permid())
    print >>sys.stderr, "permid: ", myPermid
    
    from Tribler.Main.vwxGUI.SearchGridManager import TorrentManager, LibraryManager, ChannelManager
    torrentManager = TorrentManager(None)
    libraryManager = LibraryManager(None)
    channelManager = ChannelManager()
    
    torrentManager.connect(session, libraryManager, channelManager)
    channelManager.connect(session, torrentManager)
    libraryManager.connect(session, torrentManager)
    
    myChannelName = opt.channelname or opt.nickname or 'MetadataInjector-Channel'
    myChannelName = unicode(myChannelName)
    
    myChannelId = channelManager.channelcast_db.getMyChannelId()
    if not myChannelId:
        print >> sys.stderr, "creating a new channel"
        channelManager.createChannel(myChannelName, u'')
        
    else:
        print >> sys.stderr, "reusing previously created channel"
        
        myChannel = channelManager.getChannel(myChannelId)
        if myChannel.name != myChannelName:
            print >> sys.stderr, "renaming channel to",myChannelName
            channelManager.modifyChannel(myChannelId, {'name': myChannelName})

    #use dispersythread, this way we know our channel has been created
    @forceDispersyThread
    def createTorrentFeed():
        myChannelId = channelManager.channelcast_db.getMyChannelId()

        torrentfeed = RssParser.getInstance()
        torrentfeed.register(session, myChannelId)
        torrentfeed.addCallback(myChannelId, channelManager.createTorrentFromDef)
        
        for rss in opt.rss.split(";"):
            torrentfeed.addURL(rss, myChannelId)
        
    if opt.rss:
        createTorrentFeed()
    
    #same here, using dispersythread to make sure channel has been created
    @forceDispersyThread
    def createDirFeed():
        myChannelId = channelManager.channelcast_db.getMyChannelId()
        
        def on_torrent_callback(dirpath, infohash, torrent_data):
            torrentdef = TorrentDef.load_from_dict(torrent_data)
            channelsearch_manager.createTorrentFromDef(myChannelId, torrentdef)
            
            #save torrent to collectedtorrents
            filename = torrentManager.getCollectedFilenameFromDef(torrentdef)
            if not os.path.isfile(filename): 
                torrentdef.save(filename)
        
        dirfeed = DirectoryFeedThread.getInstance()
        for dirpath in opt.dir.split(";"):
            dirfeed.addDir(dirpath, callback = on_torrent_callback)
            
    if opt.dir:
        createDirFeed()