コード例 #1
0
ファイル: script.py プロジェクト: ebcabaybay/swiftarm
 def execute_scenario_cmds(self, commands):
     torrents = []
     
     for command in commands:
         cur_command = command.split()
     
         if cur_command[0] == 'create':
             log(self._logfile, "creating-community")
             self.my_channel = ChannelCommunity.create_community(self.my_member, integrate_with_tribler = False)
             
             log(self._logfile, "creating-channel-message")
             self.my_channel.create_channel(u'', u'')
         
         elif cur_command[0] == 'publish':
             if self.my_channel:
                 infohash = str(self.torrentindex)
                 infohash += ''.join(choice(letters) for _ in xrange(20-len(infohash)))
                 
                 name = u''.join(choice(letters) for _ in xrange(100))
                 files = []
                 for _ in range(10):
                     files.append((u''.join(choice(letters) for _ in xrange(30)), 123455))
                 
                 trackers = []
                 for _ in range(10):
                     trackers.append(''.join(choice(letters) for _ in xrange(30))) 
                 
                 files = tuple(files)
                 trackers = tuple(trackers)
                 
                 self.torrentindex += 1
                 torrents.append((infohash, int(time()), name, files, trackers))
         
         elif cur_command[0] == 'post':
             if self.joined_community:
                 text = ''.join(choice(letters) for i in xrange(160))
                 self.joined_community._disp_create_comment(text, int(time()), None, None, None, None)
             
         elif cur_command[0] == 'join':
             self.want_to_join = True
             
     if self.want_to_join:
         from Tribler.dispersy.dispersy import Dispersy
         dispersy = Dispersy.get_instance()
         
         log(self._logfile, "trying-to-join-community")
         
         for community in dispersy.get_communities():
             if isinstance(community, PreviewChannelCommunity) and community._channel_id:
                 self._community.disp_create_votecast(community.cid, 2, int(time()))
                 
                 log(self._logfile, "joining-community")
                 self.joined_community = community
                 
                 self.want_to_join = False
                 break
             
     if len(torrents) > 0:
         log(self._logfile, "creating-torrents")
         self.my_channel._disp_create_torrents(torrents)
コード例 #2
0
ファイル: allchannel_client.py プロジェクト: LipuFei/gumby
    def create(self):
        msg("creating-community")
        from Tribler.community.channel.community import ChannelCommunity
        self.my_channel = ChannelCommunity.create_community(self._dispersy, self._my_member, integrate_with_tribler=False)

        msg("creating-channel-message")
        self.my_channel._disp_create_channel(u'', u'')
コード例 #3
0
ファイル: channel_manager.py プロジェクト: yorig/tribler
 def _create_channel():
     channel_mode = self._channel_mode_map[mode]
     community = ChannelCommunity.create_community(
         self.dispersy,
         self.session.dispersy_member,
         tribler_session=self.session)
     community.set_channel_mode(channel_mode)
     community.create_channel(name, description)
コード例 #4
0
    def create(self):
        msg("creating-community")
        from Tribler.community.channel.community import ChannelCommunity
        self.my_channel = ChannelCommunity.create_community(
            self._dispersy, self._my_member, integrate_with_tribler=False)

        msg("creating-channel-message")
        self.my_channel._disp_create_channel(u'', u'')
コード例 #5
0
ファイル: channel_manager.py プロジェクト: yanheven/tribler
    def create_channel(self, name, description, mode, rss_url=None):
        """
        Creates a new Channel.
        :param name: Name of the Channel.
        :param description: Description of the Channel.
        :param mode: Mode of the Channel ('open', 'semi-open', or 'closed').
        :param rss_url: RSS URL for the Channel.
        :return: Channel ID
        :raises DuplicateChannelNameError if name already exists
        """
        assert isinstance(
            name, basestring), u"name is not a basestring: %s" % type(name)
        assert isinstance(
            description, basestring
        ), u"description is not a basestring: %s" % type(description)
        assert mode in self._channel_mode_map, u"invalid mode: %s" % mode
        assert isinstance(
            rss_url, basestring
        ) or rss_url is None, u"rss_url is not a basestring or None: %s" % type(
            rss_url)

        # if two channels have the same name, this will not work
        for channel_object in self._channel_list:
            if name == channel_object.name:
                raise DuplicateChannelNameError(
                    u"Channel name already exists: %s" % name)

        channel_mode = self._channel_mode_map[mode]
        community = ChannelCommunity.create_community(
            self.dispersy,
            self.session.dispersy_member,
            tribler_session=self.session)

        channel_obj = ChannelObject(self.session, community)
        channel_obj.initialize()

        community.set_channel_mode(channel_mode)
        community.create_channel(name, description)

        # create channel object
        self._channel_list.append(channel_obj)

        if rss_url is not None:
            channel_obj.create_rss_feed(rss_url)

        self._logger.debug(u"creating channel '%s', %s", channel_obj.name,
                           hexlify(community.cid))
        return channel_obj.channel_id
コード例 #6
0
ファイル: channel_manager.py プロジェクト: synctext/tribler
    def create_channel(self, name, description, mode, rss_url=None):
        """
        Creates a new Channel.
        :param name: Name of the Channel.
        :param description: Description of the Channel.
        :param mode: Mode of the Channel ('open', 'semi-open', or 'closed').
        :param rss_url: RSS URL for the Channel.
        :return: Channel ID
        :raises DuplicateChannelNameError if name already exists
        """
        assert isinstance(name, basestring), u"name is not a basestring: %s" % type(name)
        assert isinstance(description, basestring), u"description is not a basestring: %s" % type(description)
        assert mode in self._channel_mode_map, u"invalid mode: %s" % mode
        assert isinstance(rss_url, basestring) or rss_url is None, u"rss_url is not a basestring or None: %s" % type(rss_url)

        # if two channels have the same name, this will not work
        for channel_object in self._channel_list:
            if name == channel_object.name:
                raise DuplicateChannelNameError(u"Channel name already exists: %s" % name)

        channel_mode = self._channel_mode_map[mode]
        community = ChannelCommunity.create_community(self.dispersy, self.session.dispersy_member,
                                                      tribler_session=self.session)

        channel_obj = ChannelObject(self.session, community)
        channel_obj.initialize()

        community.set_channel_mode(channel_mode)
        community.create_channel(name, description)

        # create channel object
        self._channel_list.append(channel_obj)

        if rss_url is not None:
            channel_obj.create_rss_feed(rss_url)

        self._logger.debug(u"creating channel '%s', %s", channel_obj.name, hexlify(community.cid))
        return channel_obj.channel_id
コード例 #7
0
ファイル: channel_manager.py プロジェクト: Antiade/tribler
 def _create_channel():
     channel_mode = self._channel_mode_map[mode]
     community = ChannelCommunity.create_community(self.dispersy, self.session.dispersy_member,
                                                   tribler_session=self.session)
     community.set_channel_mode(channel_mode)
     community.create_channel(name, description)