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


Python TorrentDef.set_tracker方法代码示例

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


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

示例1: subtest_add_content_dir_playtime

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def subtest_add_content_dir_playtime(self,merkle=True):
        """ Add a single dir to a TorrentDef """
        t = TorrentDef()
        t.set_create_merkle_torrent(merkle)
        fn1 = os.path.join(os.getcwd(),"contentdir","file.avi")
        fn2 = os.path.join(os.getcwd(),"contentdir","file.txt")
        t.add_content(fn1,os.path.join("dirintorrent","file.avi"),playtime=PLAYTIME)
        t.add_content(fn2,os.path.join("dirintorrent","file.txt"))
        t.set_tracker(TRACKER)
        t.finalize()

        metainfo = t.get_metainfo()
        self.general_check(metainfo)
        self.assert_(metainfo['info']['name'] == 'dirintorrent')

        s = os.path.getsize(fn1)
        
        files = metainfo['info']['files']
        for file in files:
            if file['path'][0] == "file.avi":
                self.assert_(file['playtime']==PLAYTIME)
        
        azprop = metainfo['azureus_properties']
        content = azprop['Content']
        realspeedbps = content['Speed Bps']
        expspeedbps = s/PLAYTIME_SECS
        self.assert_(realspeedbps == expspeedbps)
开发者ID:duy,项目名称:tribler,代码行数:29,代码来源:test_tdef.py

示例2: subtest_add_content_dir_and_file

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def subtest_add_content_dir_and_file(self,merkle=True):
        """ Add a single dir and single file to a TorrentDef """
        t = TorrentDef()
        t.set_create_merkle_torrent(merkle)
        
        dn = os.path.join(os.getcwd(),"contentdir")
        t.add_content(dn,"dirintorrent")
        
        fn = os.path.join(os.getcwd(),"file.wmv")
        t.add_content(fn,os.path.join("dirintorrent","file.wmv"))
        
        t.set_tracker(TRACKER)
        t.finalize()

        # Check
        exps = os.path.getsize(fn)
        for f in os.listdir("contentdir"):
            if f.startswith('.'):
                continue
            p = os.path.join("contentdir",f)
            exps += os.path.getsize(p) 

        metainfo = t.get_metainfo()
        self.general_check(metainfo)
        self.assert_(metainfo['info']['name'] == 'dirintorrent')
        
        reals = 0L
        for file in metainfo['info']['files']:
            reals += file['length']
        self.assert_(exps == reals)
开发者ID:duy,项目名称:tribler,代码行数:32,代码来源:test_tdef.py

示例3: subtest_add_content_dir

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def subtest_add_content_dir(self,merkle=True):
        """ Add a single dir to a TorrentDef """
        t = TorrentDef()
        t.set_create_merkle_torrent(merkle)
        dn = os.path.join(os.getcwd(),"contentdir")
        t.add_content(dn,"dirintorrent")
        t.set_tracker(TRACKER)
        t.finalize()

        exps = 0L
        for f in os.listdir("contentdir"):
            if f.startswith('.'):
                continue
            p = os.path.join("contentdir",f)
            s = os.path.getsize(p)
            exps += s
            print "test: expected size",f,s

        print "test: expected total size of files in torrent",exps

        metainfo = t.get_metainfo()
        self.general_check(metainfo)
        
        self.assert_(metainfo['info']['name'] == 'dirintorrent')
        reals = 0L
        for file in metainfo['info']['files']:
            s = file['length']
            print "test: real size",file['path'],s
            reals += s
            
        print "test: real size of files in torrent",reals
            
        self.assert_(exps == reals)
开发者ID:duy,项目名称:tribler,代码行数:35,代码来源:test_tdef.py

示例4: subtest_add_content_piece_length

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def subtest_add_content_piece_length(self,merkle=True):
        """ Add a single file with piece length to a TorrentDef """
        t = TorrentDef()
        t.set_create_merkle_torrent(merkle)
        fn = os.path.join(os.getcwd(),"file.wmv")
        t.add_content(fn)
        t.set_piece_length(2 ** 16)
        t.set_tracker(TRACKER)
        t.finalize()

        metainfo = t.get_metainfo()
        self.general_check(metainfo)
        self.assert_(metainfo['info']['piece length'] == 2 ** 16)
开发者ID:duy,项目名称:tribler,代码行数:15,代码来源:test_tdef.py

示例5: test_ns_metadata

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def test_ns_metadata(self):
        dummydata = "HalloWereld"
        t = TorrentDef()
        t.set_metadata(dummydata)
        fn = os.path.join(os.getcwd(),"file.wmv")
        t.add_content(fn)
        t.set_tracker(TRACKER)
        t.finalize()

        [handle,filename] = tempfile.mkstemp()
        os.close(handle)
        t.save(filename)
        
        t2 = TorrentDef.load(filename)
        self.assert_(t2.get_metadata() == dummydata)
开发者ID:duy,项目名称:tribler,代码行数:17,代码来源:test_tdef.py

示例6: subtest_add_content_torrentsig

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def subtest_add_content_torrentsig(self,merkle=True):
        """ Add a single file to a TorrentDef and sign it """
        t = TorrentDef()
        t.set_create_merkle_torrent(merkle)
        fn = os.path.join(os.getcwd(),"file.wmv")
        kpfn = os.path.join(os.getcwd(),"ec.pem")
        t.add_content(fn)
        t.set_signature_keypair_filename(kpfn)
        t.set_tracker(TRACKER)
        t.finalize()

        metainfo = t.get_metainfo()
        self.general_check(metainfo)
        ret = verify_torrent_signature(metainfo)
        self.assert_(ret == True)
开发者ID:duy,项目名称:tribler,代码行数:17,代码来源:test_tdef.py

示例7: subtest_add_content_httpseeds

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def subtest_add_content_httpseeds(self,merkle=True):
        """ Add a single file with BitTornado httpseeds to a TorrentDef """
        t = TorrentDef()
        t.set_create_merkle_torrent(merkle)
        fn = os.path.join(os.getcwd(),"file.wmv")
        t.add_content(fn)
        t.set_tracker(TRACKER)
        expseeds = ['http://www.cs.vu.nl/index.html','http://www.st.ewi.tudelft.nl/index.html']
        t.set_httpseeds(expseeds)
        t.finalize()

        metainfo = t.get_metainfo()
        self.general_check(metainfo)
        realseeds = metainfo['httpseeds']
        self.assert_(realseeds == expseeds)
开发者ID:duy,项目名称:tribler,代码行数:17,代码来源:test_tdef.py

示例8: subtest_add_content_announce_list

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def subtest_add_content_announce_list(self,merkle=True):
        """ Add a single file with announce-list to a TorrentDef """
        t = TorrentDef()
        t.set_create_merkle_torrent(merkle)
        fn = os.path.join(os.getcwd(),"file.wmv")
        t.add_content(fn)
        t.set_tracker(TRACKER)
        exphier = [[TRACKER],['http://tracker1.tribler.org:6969/announce','http://tracker2.tribler.org:7070/ann'],['http://www.cs.vu.nl','http://www.st.ewi.tudelft.nl','http://www.vuze.com']]
        t.set_tracker_hierarchy(exphier)
        t.finalize()

        metainfo = t.get_metainfo()
        self.general_check(metainfo)
        realhier = metainfo['announce-list']
        self.assert_(realhier == exphier)
开发者ID:duy,项目名称:tribler,代码行数:17,代码来源:test_tdef.py

示例9: subtest_add_content_file

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
 def subtest_add_content_file(self,merkle=True):
     """ Add a single file to a TorrentDef """
     t = TorrentDef()
     t.set_create_merkle_torrent(merkle)
     fn = os.path.join(os.getcwd(),"file.wmv")
     t.add_content(fn)
     t.set_tracker(TRACKER)
     t.finalize()
     
     s = os.path.getsize("file.wmv")
     
     metainfo = t.get_metainfo()
     self.general_check(metainfo)
     
     self.assert_(metainfo['info']['name'] == "file.wmv")
     self.assert_(metainfo['info']['length'] == s)
     
     """
开发者ID:duy,项目名称:tribler,代码行数:20,代码来源:test_tdef.py

示例10: subtest_add_content_file_playtime

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
 def subtest_add_content_file_playtime(self,merkle=True):
     """ Add a single file with playtime to a TorrentDef """
     t = TorrentDef()
     t.set_create_merkle_torrent(merkle)
     fn = os.path.join(os.getcwd(),"file.wmv")
     t.add_content(fn,playtime=PLAYTIME)
     t.set_tracker(TRACKER)
     t.finalize()
     
     s = os.path.getsize("file.wmv")
     
     metainfo = t.get_metainfo()
     self.general_check(metainfo)
     self.assert_(metainfo['info']['playtime']==PLAYTIME)
     azprop = metainfo['azureus_properties']
     content = azprop['Content']
     realspeedbps = content['Speed Bps']
     expspeedbps = s/PLAYTIME_SECS
     self.assert_(realspeedbps == expspeedbps)
开发者ID:duy,项目名称:tribler,代码行数:21,代码来源:test_tdef.py

示例11: subtest_add_content_file_save

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def subtest_add_content_file_save(self,merkle=True):
        """ Add a single file to a TorrentDef and save the latter"""
        t = TorrentDef()
        t.set_create_merkle_torrent(merkle)
        fn = os.path.join(os.getcwd(),"file.wmv")
        t.add_content(fn)
        t.set_tracker(TRACKER)
        t.finalize()

        tfn = os.path.join(os.getcwd(),"gen.torrent")
        t.save(tfn)
        
        f = open(tfn,"rb")
        bdata = f.read()
        f.close()
        os.remove(tfn)
        
        data = bdecode(bdata)
        metainfo = t.get_metainfo()
        self.general_check(metainfo)
        self.assert_(metainfo == data)
开发者ID:duy,项目名称:tribler,代码行数:23,代码来源:test_tdef.py

示例12: subtest_add_content_file_thumbnail

# 需要导入模块: from Tribler.Core.API import TorrentDef [as 别名]
# 或者: from Tribler.Core.API.TorrentDef import set_tracker [as 别名]
    def subtest_add_content_file_thumbnail(self,merkle=True):
        """ Add a single file with thumbnail to a TorrentDef """
        t = TorrentDef()
        t.set_create_merkle_torrent(merkle)
        fn = os.path.join(os.getcwd(),"file.wmv")
        thumbfn = os.path.join(os.getcwd(),"thumb.jpg")
        t.add_content(fn)
        t.set_thumbnail(thumbfn)
        t.set_tracker(TRACKER)
        t.finalize()

        f = open(thumbfn,"rb")
        expthumb = f.read()
        f.close()
        
        metainfo = t.get_metainfo()
        self.general_check(metainfo)
        azprop = metainfo['azureus_properties']
        content = azprop['Content']
        realthumb = content['Thumbnail']
        self.assert_(realthumb == expthumb)
开发者ID:duy,项目名称:tribler,代码行数:23,代码来源:test_tdef.py


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