当前位置: 首页>>代码示例>>Python>>正文


Python tribler_request_manager.TriblerRequestManager类代码示例

本文整理汇总了Python中TriblerGUI.tribler_request_manager.TriblerRequestManager的典型用法代码示例。如果您正苦于以下问题:Python TriblerRequestManager类的具体用法?Python TriblerRequestManager怎么用?Python TriblerRequestManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TriblerRequestManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_torrents_remove_all_action

    def on_torrents_remove_all_action(self, action):
        if action == 0:
            request_mgr = TriblerRequestManager()
            request_mgr.perform_request("mychannel/torrents", self.on_all_torrents_removed_response, method='DELETE')

        self.dialog.close_dialog()
        self.dialog = None
开发者ID:Tribler,项目名称:tribler,代码行数:7,代码来源:editchannelpage.py

示例2: add_torrent_to_channel

 def add_torrent_to_channel(self, filename):
     with open(filename, "rb") as torrent_file:
         torrent_content = b64encode(torrent_file.read())
         request_mgr = TriblerRequestManager()
         request_mgr.perform_request("mychannel/torrents",
                                     self.on_torrent_to_channel_added, method='PUT',
                                     data={"torrent": torrent_content})
开发者ID:Tribler,项目名称:tribler,代码行数:7,代码来源:editchannelpage.py

示例3: initialize_with_channel

    def initialize_with_channel(self, channel_info):
        self.playlists = []
        self.torrents = []
        self.loaded_channels = False
        self.loaded_playlists = False

        self.get_torents_in_channel_manager = None
        self.get_playlists_in_channel_manager = None

        self.channel_info = channel_info

        self.window().channel_torrents_list.set_data_items([(LoadingListItem, None)])
        self.window().channel_torrents_detail_widget.hide()

        self.window().channel_preview_label.setHidden(channel_info['subscribed'])
        self.window().channel_back_button.setIcon(QIcon(get_image_path('page_back.png')))

        self.get_torents_in_channel_manager = TriblerRequestManager()
        self.get_torents_in_channel_manager.perform_request("channels/discovered/%s/torrents" %
                                                            channel_info['dispersy_cid'],
                                                            self.received_torrents_in_channel)

        if len(channel_info['dispersy_cid']) == 148: # Check-hack for Channel2.0 style address
            self.loaded_playlists = True
        else:
            self.get_playlists_in_channel_manager = TriblerRequestManager()
            self.get_playlists_in_channel_manager.perform_request("channels/discovered/%s/playlists" %
                                                                  channel_info['dispersy_cid'],
                                                                  self.received_playlists_in_channel)

        # initialize the page about a channel
        self.window().channel_name_label.setText(channel_info['name'])
        self.window().num_subs_label.setText(str(channel_info['votes']))
        self.window().subscription_widget.initialize_with_channel(channel_info)
开发者ID:synctext,项目名称:tribler,代码行数:34,代码来源:channelpage.py

示例4: on_export_download_dialog_done

        def on_export_download_dialog_done(action):
            if action == 0:
                dest_path = os.path.join(export_dir, dialog.dialog_widget.dialog_input.text())
                request_mgr = TriblerRequestManager()
                request_mgr.download_file("channels/discovered/%s/mdblob" % mdblob_name,
                                          lambda data: on_export_download_request_done(dest_path, data))

            dialog.close_dialog()
开发者ID:synctext,项目名称:tribler,代码行数:8,代码来源:editchannelpage.py

示例5: add_torrent_to_channel

 def add_torrent_to_channel(self, filename):
     with open(filename, "rb") as torrent_file:
         torrent_content = urllib.quote_plus(base64.b64encode(torrent_file.read()))
         editchannel_request_mgr = TriblerRequestManager()
         editchannel_request_mgr.perform_request("channels/discovered/%s/torrents" %
                                                      self.channel_overview['identifier'],
                                                      self.on_torrent_to_channel_added, method='PUT',
                                                      data='torrent=%s' % torrent_content)
开发者ID:synctext,项目名称:tribler,代码行数:8,代码来源:editchannelpage.py

示例6: add_dir_to_channel

 def add_dir_to_channel(self, dirname, recursive=False):
     post_data = {
         "torrents_dir": dirname,
         "recursive": int(recursive)
     }
     request_mgr = TriblerRequestManager()
     request_mgr.perform_request("mychannel/torrents",
                                 self.on_torrent_to_channel_added, method='PUT', data=post_data)
开发者ID:Tribler,项目名称:tribler,代码行数:8,代码来源:editchannelpage.py

示例7: SubscribedChannelsPage

class SubscribedChannelsPage(QWidget):
    """
    This page shows all the channels that the user has subscribed to.
    """

    def __init__(self):
        QWidget.__init__(self)

        self.dialog = None
        self.request_mgr = None

    def initialize(self):
        self.window().add_subscription_button.clicked.connect(self.on_add_subscription_clicked)

    def load_subscribed_channels(self):
        self.window().subscribed_channels_list.set_data_items([(LoadingListItem, None)])

        self.request_mgr = TriblerRequestManager()
        self.request_mgr.perform_request("channels/subscribed", self.received_subscribed_channels)

    def received_subscribed_channels(self, results):
        if not results:
            return
        self.window().subscribed_channels_list.set_data_items([])
        items = []

        if len(results['subscribed']) == 0:
            self.window().subscribed_channels_list.set_data_items(
                [(LoadingListItem, "You are not subscribed to any channel.")])
            return

        for result in results['subscribed']:
            items.append((ChannelListItem, result))
        self.window().subscribed_channels_list.set_data_items(items)

    def on_add_subscription_clicked(self):
        self.dialog = ConfirmationDialog(self, "Add subscribed channel",
                                         "Please enter the identifier of the channel you want to subscribe to below. "
                                         "It can take up to a minute before the channel is visible in your list of "
                                         "subscribed channels.",
                                         [('ADD', BUTTON_TYPE_NORMAL), ('CANCEL', BUTTON_TYPE_CONFIRM)],
                                         show_input=True)
        self.dialog.dialog_widget.dialog_input.setPlaceholderText('Channel identifier')
        self.dialog.button_clicked.connect(self.on_subscription_added)
        self.dialog.show()

    def on_subscription_added(self, action):
        if action == 0:
            self.request_mgr = TriblerRequestManager()
            self.request_mgr.perform_request("channels/subscribed/%s" % self.dialog.dialog_widget.dialog_input.text(),
                                             self.on_channel_subscribed, method='PUT')

        self.dialog.close_dialog()
        self.dialog = None

    def on_channel_subscribed(self, _):
        pass
开发者ID:synctext,项目名称:tribler,代码行数:57,代码来源:subscribedchannelspage.py

示例8: on_commit_control_clicked

    def on_commit_control_clicked(self, index):
        infohash = index.model().data_items[index.row()][u'infohash']
        status = index.model().data_items[index.row()][u'status']

        new_status = COMMIT_STATUS_COMMITTED
        if status == COMMIT_STATUS_NEW or status == COMMIT_STATUS_COMMITTED:
            new_status = COMMIT_STATUS_TODELETE

        request_mgr = TriblerRequestManager()
        request_mgr.perform_request("mychannel/torrents/%s" % infohash,
                                    lambda response: self.on_torrent_status_updated(response, index),
                                    data={"status": new_status}, method='PATCH')
开发者ID:Tribler,项目名称:tribler,代码行数:12,代码来源:lazytableview.py

示例9: on_subscribe_control_clicked

 def on_subscribe_control_clicked(self, index):
     item = index.model().data_items[index.row()]
     # skip LEGACY entries, regular torrents and personal channel
     if (u'subscribed' not in item or
             item[u'status'] == 1000 or
             item[u'my_channel']):
         return
     status = int(item[u'subscribed'])
     public_key = item[u'public_key']
     request_mgr = TriblerRequestManager()
     request_mgr.perform_request("metadata/channels/%s" % public_key,
                                 (lambda _: self.on_unsubscribed_channel.emit(index)) if status else
                                 (lambda _: self.on_subscribed_channel.emit(index)),
                                 data={"subscribe": int(not status)}, method='POST')
     index.model().data_items[index.row()][u'subscribed'] = int(not status)
开发者ID:Tribler,项目名称:tribler,代码行数:15,代码来源:lazytableview.py

示例10: on_confirm_partially_empty_tokens

 def on_confirm_partially_empty_tokens(self, action, tokens):
     self.confirm_empty_tokens_dialog.close_dialog()
     self.confirm_empty_tokens_dialog = None
     if action == 0:
         self.trustchain_request_mgr = TriblerRequestManager()
         self.trustchain_request_mgr.perform_request("trustchain/bootstrap?amount=%d" % (tokens * MEBIBYTE),
                                                     self.on_emptying_tokens)
开发者ID:Tribler,项目名称:tribler,代码行数:7,代码来源:settingspage.py

示例11: load_my_channel_overview

    def load_my_channel_overview(self):
        if not self.channel_overview:
            self.window().edit_channel_stacked_widget.setCurrentIndex(2)

        self.editchannel_request_mgr = TriblerRequestManager()
        self.editchannel_request_mgr.perform_request("mychannel", self.initialize_with_channel_overview,
                                                     capture_errors=False)
开发者ID:synctext,项目名称:tribler,代码行数:7,代码来源:editchannelpage.py

示例12: on_torrents_remove_all_action

    def on_torrents_remove_all_action(self, action):
        if action == 0:
            for torrent_ind in xrange(self.window().edit_channel_torrents_list.count()):
                torrent_data = self.window().edit_channel_torrents_list.item(torrent_ind).data(Qt.UserRole)
                request_mgr = TriblerRequestManager()
                request_mgr.perform_request("channels/discovered/%s/torrents/%s" %
                                            (self.channel_overview["identifier"], torrent_data['infohash']),
                                            None, method='DELETE')
                self.remove_torrent_requests.append(request_mgr)

            self.window().edit_channel_torrents_list.set_data_items([])
            if "chant" in self.channel_overview:
                self.load_channel_torrents()

        self.dialog.close_dialog()
        self.dialog = None
开发者ID:synctext,项目名称:tribler,代码行数:16,代码来源:editchannelpage.py

示例13: on_confirm_fully_empty_tokens

    def on_confirm_fully_empty_tokens(self, action):
        self.confirm_empty_tokens_dialog.close_dialog()
        self.confirm_empty_tokens_dialog = None

        if action == 0:
            self.trustchain_request_mgr = TriblerRequestManager()
            self.trustchain_request_mgr.perform_request("trustchain/bootstrap", self.on_emptying_tokens)
开发者ID:Tribler,项目名称:tribler,代码行数:7,代码来源:settingspage.py

示例14: received_settings

    def received_settings(self, settings):
        if not settings:
            return
        # If we cannot receive the settings, stop Tribler with an option to send the crash report.
        if 'error' in settings:
            raise RuntimeError(TriblerRequestManager.get_message_from_error(settings))

        self.tribler_settings = settings['settings']

        # Set the video server port
        self.video_player_page.video_player_port = settings["ports"]["video_server~port"]

        # Disable various components based on the settings
        if not self.tribler_settings['video_server']['enabled']:
            self.left_menu_button_video_player.setHidden(True)
        self.downloads_creditmining_button.setHidden(not self.tribler_settings["credit_mining"]["enabled"])
        self.downloads_all_button.click()

        # process pending file requests (i.e. someone clicked a torrent file when Tribler was closed)
        # We do this after receiving the settings so we have the default download location.
        self.process_uri_request()

        # Set token balance refresh timer and load the token balance
        self.token_refresh_timer = QTimer()
        self.token_refresh_timer.timeout.connect(self.load_token_balance)
        self.token_refresh_timer.start(60000)

        self.load_token_balance()
开发者ID:Tribler,项目名称:tribler,代码行数:28,代码来源:tribler_window.py

示例15: update_with_torrent

    def update_with_torrent(self, torrent_info):
        self.torrent_info = torrent_info
        self.is_health_checking = False
        self.torrent_detail_name_label.setText(self.torrent_info["name"])
        if self.torrent_info["category"]:
            self.torrent_detail_category_label.setText(self.torrent_info["category"].lower())
        else:
            self.torrent_detail_category_label.setText("unknown")

        if self.torrent_info["size"] is None:
            self.torrent_detail_size_label.setText("Size: -")
        else:
            self.torrent_detail_size_label.setText("%s" % format_size(float(self.torrent_info["size"])))

        if self.torrent_info["num_seeders"] > 0:
            self.torrent_detail_health_label.setText("good health (S%d L%d)" % (self.torrent_info["num_seeders"],
                                                                                self.torrent_info["num_leechers"]))
        elif self.torrent_info["num_leechers"] > 0:
            self.torrent_detail_health_label.setText("unknown health (found peers)")
        else:
            self.torrent_detail_health_label.setText("no peers found")

        self.setCurrentIndex(0)
        self.setTabEnabled(1, False)
        self.setTabEnabled(2, False)

        self.request_mgr = TriblerRequestManager()
        self.request_mgr.perform_request("torrents/%s" % self.torrent_info["infohash"], self.on_torrent_info)
开发者ID:synctext,项目名称:tribler,代码行数:28,代码来源:torrentdetailstabwidget.py


注:本文中的TriblerGUI.tribler_request_manager.TriblerRequestManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。