當前位置: 首頁>>代碼示例>>Python>>正文


Python plugin_rtorrent.RTorrent類代碼示例

本文整理匯總了Python中flexget.plugins.plugin_rtorrent.RTorrent的典型用法代碼示例。如果您正苦於以下問題:Python RTorrent類的具體用法?Python RTorrent怎麽用?Python RTorrent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了RTorrent類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_load

    def test_load(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.execute.throw.return_value = 0
        mocked_proxy.load.raw_start.return_value = 0

        client = RTorrent('http://localhost/RPC2')

        resp = client.load(
            torrent_raw,
            fields={'priority': 3, 'directory': '/data/downloads', 'custom1': 'testing'},
            start=True,
            mkdir=True,
        )

        assert resp == 0

        # Ensure mkdir was called
        mocked_proxy.execute.throw.assert_called_with('', 'mkdir', '-p', '/data/downloads')

        # Ensure load was called
        assert mocked_proxy.load.raw_start.called

        match_binary = Matcher(compare_binary, xmlrpc_client.Binary(torrent_raw))

        called_args = mocked_proxy.load.raw_start.call_args_list[0][0]
        assert len(called_args) == 5
        assert '' == called_args[0]
        assert match_binary in called_args

        fields = [p for p in called_args[2:]]
        assert len(fields) == 3
        assert 'd.directory.set=\\/data\\/downloads' in fields
        assert 'd.custom1.set=testing' in fields
        assert 'd.priority.set=3' in fields
開發者ID:Farbdose,項目名稱:Flexget,代碼行數:34,代碼來源:test_rtorrent.py

示例2: test_torrents

    def test_torrents(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        hash1 = '09977FE761AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        hash2 = '09977FE761BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'

        mocked_proxy.d.multicall.return_value = (
            ['/data/downloads', 'private.torrent', hash1, 'test_custom1'],
            ['/data/downloads', 'private.torrent', hash2, 'test_custom2'],
        )

        client = RTorrent('http://localhost/RPC2')
        torrents = client.torrents(fields=['custom1'])  # Required fields should be added

        assert isinstance(torrents, list)

        for torrent in torrents:
            assert torrent.get('base_path') == '/data/downloads'
            assert torrent.get('name') == 'private.torrent'

            if torrent.get('hash') == hash1:
                assert torrent.get('custom1') == 'test_custom1'
            elif torrent.get('hash') == hash2:
                assert torrent.get('custom1') == 'test_custom2'
            else:
                assert False, 'Invalid hash returned'

        assert mocked_proxy.system.multicall.called_with((
            ['main', 'd.directory_base=', 'd.name=', 'd.hash=', u'd.custom1='],
        ))
開發者ID:Farbdose,項目名稱:Flexget,代碼行數:29,代碼來源:test_rtorrent.py

示例3: test_load

    def test_load(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.execute.throw.return_value = 0
        mocked_proxy.load.raw_start.return_value = 0

        client = RTorrent('http://localhost/RPC2')

        resp = client.load(
            torrent_raw,
            fields={'priority': 3, 'directory': '/data/downloads', 'custom1': 'test_custom1'},
            start=True,
            mkdir=True,
        )

        assert resp == 0

        # Ensure mkdir was called
        mocked_proxy.execute.throw.assert_called_with('', 'mkdir', '-p', '/data/downloads')

        # Ensure load was called
        match_binary = Matcher(compare_binary, xmlrpclib.Binary(torrent_raw))
        mocked_proxy.load.raw_start.assert_called_with(
            '',
            match_binary,
            'd.priority.set=3',
            'd.directory.set=\\/data\\/downloads',
            'd.custom1.set=test\\_custom1'
        )
開發者ID:Ekhozie,項目名稱:Flexget,代碼行數:28,代碼來源:test_rtorrent.py

示例4: test_start

    def test_start(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.d.start.return_value = 0

        client = RTorrent('http://localhost/RPC2')
        resp = client.start(torrent_info_hash)

        assert resp == 0
        assert mocked_proxy.d.start.called_with((torrent_info_hash,))
開發者ID:Farbdose,項目名稱:Flexget,代碼行數:9,代碼來源:test_rtorrent.py

示例5: test_move

    def test_move(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.system.multicall.return_value = [
            ['private.torrent'], [torrent_info_hash], ['/data/downloads'],
        ]

        mocked_proxy.move.return_value = 0
        mocked_proxy.d.directory.set.return_value = 0
        mocked_proxy.execute.throw.return_value = 0

        client = RTorrent('http://localhost/RPC2')
        client.move(torrent_info_hash, '/new/folder')

        mocked_proxy.execute.throw.assert_has_calls([
            mock.call('', 'mkdir', '-p', '/new/folder'),
            mock.call('', 'mv', '-u', '/data/downloads', '/new/folder'),
        ])
開發者ID:Farbdose,項目名稱:Flexget,代碼行數:17,代碼來源:test_rtorrent.py

示例6: test_update

    def test_update(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.system.multicall.return_value = [[0]]

        client = RTorrent('http://localhost/RPC2')

        update_fields = {
            'custom1': 'test_custom1',
            'directory_base': '/data/downloads',
            'priority': 3,
        }

        resp = client.update(torrent_info_hash, fields=update_fields)
        assert resp == 0

        assert mocked_proxy.system.multicall.called_with(([
            {'params': (torrent_info_hash, '/data/downloads'), 'methodName': 'd.directory_base'},
            {'params': (torrent_info_hash, 'test_custom1'), 'methodName': 'd.custom1'},
            {'params': (torrent_info_hash, '/data/downloads'), 'methodName': 'd.custom1'}
        ]))
開發者ID:Farbdose,項目名稱:Flexget,代碼行數:20,代碼來源:test_rtorrent.py

示例7: test_torrent

    def test_torrent(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.system.multicall.return_value = [
            ['/data/downloads'], ['private.torrent'], [torrent_info_hash], ['test_custom1'], [123456]
        ]

        client = RTorrent('http://localhost/RPC2')

        torrent = client.torrent(torrent_info_hash, fields=['custom1', 'down_rate'])  # Required fields should be added

        assert isinstance(torrent, dict)
        assert torrent.get('base_path') == '/data/downloads'
        assert torrent.get('hash') == torrent_info_hash
        assert torrent.get('custom1') == 'test_custom1'
        assert torrent.get('name') == 'private.torrent'
        assert torrent.get('down_rate') == 123456

        assert mocked_proxy.system.multicall.called_with(([
            {'params': (torrent_info_hash,), 'methodName': 'd.base_path'},
            {'params': (torrent_info_hash,), 'methodName': 'd.name'},
            {'params': (torrent_info_hash,), 'methodName': 'd.hash'},
            {'params': (torrent_info_hash,), 'methodName': 'd.custom1'},
            {'params': (torrent_info_hash,), 'methodName': 'd.down.rate'},
        ]))
開發者ID:Farbdose,項目名稱:Flexget,代碼行數:24,代碼來源:test_rtorrent.py


注:本文中的flexget.plugins.plugin_rtorrent.RTorrent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。