本文整理汇总了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