merged python fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-03-29 02:46:12 +00:00
parent d21243dc9f
commit dfe541ecec
4 changed files with 29 additions and 15 deletions

View File

@ -20,7 +20,7 @@
* fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP
* add missing functions to python binding (flush_cache() and remap_files())
* add missing functions to python binding (flush_cache(), remap_files() and orig_files())
* improve handling of filenames that are invalid on windows
* support 'implied_port' in DHT announce_peer
* don't use pool allocator for disk blocks (cache may now return pages to the kernel)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# Copyright Daniel Wallin 2006. Use, modification and distribution is
# subject to the Boost Software License, Version 1.0. (See accompanying
@ -117,11 +117,11 @@ def print_peer_info(console, peers):
out += progress_bar(0, 15)
out += ' '
if p.flags & lt.peer_info.handshake:
if p.flags & lt.peer_info.handshake:
id = 'waiting for handshake'
elif p.flags & lt.peer_info.connecting:
elif p.flags & lt.peer_info.connecting:
id = 'connecting to peer'
elif p.flags & lt.peer_info.queued:
elif p.flags & lt.peer_info.queued:
id = 'queued'
else:
id = p.client
@ -156,22 +156,22 @@ def main():
parser = OptionParser()
parser.add_option('-p', '--port',
parser.add_option('-p', '--port',
type='int', help='set listening port')
parser.add_option('-d', '--max-download-rate',
parser.add_option('-d', '--max-download-rate',
type='float', help='the maximum download rate given in kB/s. 0 means infinite.')
parser.add_option('-u', '--max-upload-rate',
parser.add_option('-u', '--max-upload-rate',
type='float', help='the maximum upload rate given in kB/s. 0 means infinite.')
parser.add_option('-s', '--save-path',
parser.add_option('-s', '--save-path',
type='string', help='the path where the downloaded file/folder should be placed.')
parser.add_option('-a', '--allocation-mode',
parser.add_option('-a', '--allocation-mode',
type='string', help='sets mode used for allocating the downloaded files on disk. Possible options are [full | compact]')
parser.add_option('-r', '--proxy-host',
parser.add_option('-r', '--proxy-host',
type='string', help='sets HTTP proxy host and port (separated by \':\')')
parser.set_defaults(

View File

@ -1,8 +1,8 @@
#!/bin/python
#!/usr/bin/env python
# Copyright Arvid Norberg 2008. Use, modification and distribution is
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
from __future__ import print_function
import libtorrent as lt
import time
@ -28,4 +28,3 @@ while (not h.is_seed()):
time.sleep(1)
print(h.name(), 'complete')

View File

@ -71,6 +71,17 @@ namespace
return result;
}
list orig_files(torrent_info const& ti, bool storage) {
list result;
file_storage const& st = ti.orig_files();
for (int i = 0; i < st.num_files(); ++i)
result.append(st.at(i));
return result;
}
std::string hash_for_piece(torrent_info const& ti, int i)
{
return ti.hash_for_piece(i).to_string();
@ -111,6 +122,8 @@ namespace
size_type get_size(file_entry const& fe) { return fe.size; }
size_type get_offset(file_entry const& fe) { return fe.offset; }
size_type get_file_base(file_entry const& fe) { return fe.file_base; }
void set_file_base(file_entry& fe, int b) { fe.file_base = b; }
bool get_pad_file(file_entry const& fe) { return fe.pad_file; }
bool get_executable_attribute(file_entry const& fe) { return fe.executable_attribute; }
bool get_hidden_attribute(file_entry const& fe) { return fe.hidden_attribute; }
@ -162,9 +175,10 @@ void bind_torrent_info()
.def("piece_size", &torrent_info::piece_size)
.def("num_files", &torrent_info::num_files, (arg("storage")=false))
.def("file_at", &torrent_info::file_at)
.def("file_at", &torrent_info::file_at)
.def("file_at_offset", &torrent_info::file_at_offset)
.def("files", &files, (arg("storage")=false))
.def("orig_files", &orig_files, (arg("storage")=false))
.def("rename_file", rename_file0)
#if TORRENT_USE_WSTRING
.def("rename_file", rename_file1)
@ -194,6 +208,7 @@ void bind_torrent_info()
.add_property("symlink_attribute", &get_symlink_attribute)
.add_property("offset", &get_offset)
.add_property("size", &get_size)
.add_property("file_base", &get_file_base, &set_file_base)
;
class_<announce_entry>("announce_entry", init<std::string const&>())