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


Python DownloadStartupConfig.set_safe_seeding方法代码示例

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


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

示例1: create_dconfig_from_params

# 需要导入模块: from Tribler.Core.DownloadConfig import DownloadStartupConfig [as 别名]
# 或者: from Tribler.Core.DownloadConfig.DownloadStartupConfig import set_safe_seeding [as 别名]
    def create_dconfig_from_params(parameters):
        """
        Create a download configuration based on some given parameters. Possible parameters are:
        - anon_hops: the number of hops for the anonymous download. 0 hops is equivalent to a plain download
        - safe_seeding: whether the seeding of the download should be anonymous or not (0 = off, 1 = on)
        - destination: the destination path of the torrent (where it is saved on disk)
        """
        download_config = DownloadStartupConfig()

        anon_hops = 0
        if 'anon_hops' in parameters and len(parameters['anon_hops']) > 0:
            if parameters['anon_hops'][0].isdigit():
                anon_hops = int(parameters['anon_hops'][0])

        safe_seeding = False
        if 'safe_seeding' in parameters and len(parameters['safe_seeding']) > 0 \
                and parameters['safe_seeding'][0] == "1":
            safe_seeding = True

        if anon_hops > 0 and not safe_seeding:
            return None, "Cannot set anonymous download without safe seeding enabled"

        if anon_hops > 0:
            download_config.set_hops(anon_hops)

        if safe_seeding:
            download_config.set_safe_seeding(True)

        if 'destination' in parameters and len(parameters['destination']) > 0:
            dest_dir = cast_to_unicode_utf8(parameters['destination'][0])
            download_config.set_dest_dir(dest_dir)

        if 'selected_files[]' in parameters:
            selected_files_list = [cast_to_unicode_utf8(f) for f in parameters['selected_files[]']]
            download_config.set_selected_files(selected_files_list)

        return download_config, None
开发者ID:Tribler,项目名称:tribler,代码行数:39,代码来源:downloads_endpoint.py


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