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


Python DownloadStartupConfig.set_proxyservice_role方法代码示例

本文整理汇总了Python中Tribler.Core.DownloadConfig.DownloadStartupConfig.set_proxyservice_role方法的典型用法代码示例。如果您正苦于以下问题:Python DownloadStartupConfig.set_proxyservice_role方法的具体用法?Python DownloadStartupConfig.set_proxyservice_role怎么用?Python DownloadStartupConfig.set_proxyservice_role使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tribler.Core.DownloadConfig.DownloadStartupConfig的用法示例。


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

示例1: new_download

# 需要导入模块: from Tribler.Core.DownloadConfig import DownloadStartupConfig [as 别名]
# 或者: from Tribler.Core.DownloadConfig.DownloadStartupConfig import set_proxyservice_role [as 别名]
    def new_download(self, permid, infohash, torrent_data):
        """ Start a new download in order to get the pieces that will be requested by the doe.
        After the download is started, find the appropriate proxy object and call it's method.
        
        @param permid: The permid of the peer who sent the message
        @param infohash: the infohash of the torrent for which relay is requested
        @param torrent_data: the content of the .torrent file
        """

        # Create the name for the .torrent file in the proxy cache
        basename = binascii.hexlify(infohash) + ".torrent"
        torrentfilename = os.path.join(self.proxydir, basename)

        # Write the .torrent information in the .torrent proxy cache file
        tfile = open(torrentfilename, "wb")
        tfile.write(torrent_data)
        tfile.close()

        if DEBUG:
            print >>sys.stderr, "proxy: new_download: Got metadata required for relaying"
            print >>sys.stderr, "proxy: new_download: torrent: ", torrentfilename

        tdef = TorrentDef.load(torrentfilename)
        if self.dlconfig is None:
            dscfg = DownloadStartupConfig()
        else:
            dscfg = DownloadStartupConfig(self.dlconfig)
        dscfg.set_proxyservice_role(PROXYSERVICE_ROLE_PROXY)
        dscfg.set_dest_dir(self.proxydir)
        dscfg.set_doe_mode(DOE_MODE_OFF)  # a proxy does not use other proxies for downloading data in the current stage

        # Start new download
        if DEBUG:
            print >>sys.stderr, "proxy: new_download: Starting a new download"

        self.session.add_observer(self.proxydownloader_started, NTFY_PROXYDOWNLOADER, [NTFY_STARTED])

        d = self.session.start_download(tdef, dscfg)
        d.set_state_callback(self.state_callback, getpeerlist=False)
开发者ID:hawkstalion,项目名称:Tribler,代码行数:41,代码来源:ProxyMessageHandler.py


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