本文整理汇总了Python中tracker.Tracker.download_torrent方法的典型用法代码示例。如果您正苦于以下问题:Python Tracker.download_torrent方法的具体用法?Python Tracker.download_torrent怎么用?Python Tracker.download_torrent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracker.Tracker
的用法示例。
在下文中一共展示了Tracker.download_torrent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Cloud
# 需要导入模块: from tracker import Tracker [as 别名]
# 或者: from tracker.Tracker import download_torrent [as 别名]
#.........这里部分代码省略.........
return True
else:
return False
def get_files(self, torr_hash_l):
"""
Download our files, given a torrent's info hash (string) or a list of torrent info hashes (strings). Used by the get() function to pull down data
files from the cloud.
Parameters
torr_hash_l: string, or list of strings
"""
self.session.serve_torrent_by_hash(torr_hash_l, self.torr_dir, self.data_dir, self.my_tracker.tracker_ip, self.ext)
def serve_torrents(self):
"""
Serve up all torrents in our torr directory. Does not take any parameters, simply checks for all torrents
in our torrent meta data directory, and serves them.
"""
self.session.serve_all_torrents(self.torr_dir, self.data_dir, self.my_tracker.tracker_ip, self.ext)
def get_torrents(self, torr_hash_l):
"""
Pull a torrent down from the tracker by ID.
Parameter
torr_hash_l: list or string of info hashes of torrents to download from the tracker.
"""
flag = 0
if hasattr(torr_hash_l, '__iter__'):
for t in torr_hash_l:
torr_loc = self.my_tracker.download_torrent(t, self.torr_dir)
if not torr_loc:
log.debug("Multiple Torr ID's: unable to get torrent location.")
flag = 1
else:
torr_loc = self.my_tracker.download_torrent(torr_hash_l, self.torr_dir)
if not torr_loc:
log.debug("Single ID: unable to get torrent location.")
flag = 1
if flag:
return False
else:
return True
# Mark for removal ?
def get_files_by_torr_name(self, torr_name_l):
"""
Download files given a torrent file name. This function will likely be going away as it's not part of our workflow at the moment.
Parameters
torr_name_l: string or list of torrent info hashes
"""
# setup our TorrentMetaInfo object and create a torrent
if hasattr(torr_name_l, '__iter__'):
for t in torr_name_l:
ti = TorrentMetaInfo(self.torr_dir, self.data_dir, self.my_tracker.tracker_ip, torr_file=t)
self.session.serve(ti)
else:
ti = TorrentMetaInfo(self.torr_dir, self.data_dir, self.my_tracker.tracker_ip, torr_file=torr_name_l)
self.session.serve(ti)