forked from premiere/premiere-libtorrent
python binding update
This commit is contained in:
parent
bfa7dd7b75
commit
2b144d7ac7
|
@ -9,27 +9,47 @@
|
|||
using namespace boost::python;
|
||||
using namespace libtorrent;
|
||||
|
||||
int get_last_active(peer_info const& pi)
|
||||
{
|
||||
return total_seconds(pi.last_active);
|
||||
}
|
||||
|
||||
int get_last_request(peer_info const& pi)
|
||||
{
|
||||
return total_seconds(pi.last_request);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
str get_country(peer_info const& pi)
|
||||
{
|
||||
return str(pi.country, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
tuple get_ip(peer_info const& pi)
|
||||
{
|
||||
return make_tuple(boost::lexical_cast<std::string>(pi.ip.address()), pi.ip.port());
|
||||
return make_tuple(boost::lexical_cast<std::string>(pi.ip.address()), pi.ip.port());
|
||||
}
|
||||
|
||||
list get_pieces(peer_info const& pi)
|
||||
{
|
||||
list ret;
|
||||
list ret;
|
||||
|
||||
for (std::vector<bool>::const_iterator i = pi.pieces.begin()
|
||||
, end(pi.pieces.end()); i != end; ++i)
|
||||
{
|
||||
ret.append(*i);
|
||||
}
|
||||
return ret;
|
||||
for (std::vector<bool>::const_iterator i = pi.pieces.begin()
|
||||
, end(pi.pieces.end()); i != end; ++i)
|
||||
{
|
||||
ret.append(*i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bind_peer_info()
|
||||
{
|
||||
scope pi = class_<peer_info>("peer_info")
|
||||
.def_readonly("flags", &peer_info::flags)
|
||||
.def_readonly("source", &peer_info::source)
|
||||
.def_readonly("read_state", &peer_info::read_state)
|
||||
.def_readonly("write_state", &peer_info::write_state)
|
||||
.add_property("ip", get_ip)
|
||||
.def_readonly("up_speed", &peer_info::up_speed)
|
||||
.def_readonly("down_speed", &peer_info::down_speed)
|
||||
|
@ -41,18 +61,32 @@ void bind_peer_info()
|
|||
.add_property("pieces", get_pieces)
|
||||
.def_readonly("upload_limit", &peer_info::upload_limit)
|
||||
.def_readonly("download_limit", &peer_info::download_limit)
|
||||
.add_property("last_request", get_last_request)
|
||||
.add_property("last_active", get_last_active)
|
||||
.def_readonly("send_buffer_size", &peer_info::send_buffer_size)
|
||||
.def_readonly("used_send_buffer", &peer_info::used_send_buffer)
|
||||
.def_readonly("num_hashfails", &peer_info::num_hashfails)
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
.add_property("country", get_country)
|
||||
#endif
|
||||
.def_readonly("load_balancing", &peer_info::load_balancing)
|
||||
.def_readonly("download_queue_length", &peer_info::download_queue_length)
|
||||
.def_readonly("upload_queue_length", &peer_info::upload_queue_length)
|
||||
.def_readonly("failcount", &peer_info::failcount)
|
||||
.def_readonly("downloading_piece_index", &peer_info::downloading_piece_index)
|
||||
.def_readonly("downloading_block_index", &peer_info::downloading_block_index)
|
||||
.def_readonly("downloading_progress", &peer_info::downloading_progress)
|
||||
.def_readonly("downloading_total", &peer_info::downloading_total)
|
||||
.def_readonly("client", &peer_info::client)
|
||||
.def_readonly("connection_type", &peer_info::connection_type)
|
||||
.def_readonly("source", &peer_info::source)
|
||||
.def_readonly("remote_dl_rate", &peer_info::remote_dl_rate)
|
||||
.def_readonly("pending_disk_bytes", &peer_info::pending_disk_bytes)
|
||||
.def_readonly("send_quota", &peer_info::send_quota)
|
||||
.def_readonly("receive_quota", &peer_info::receive_quota)
|
||||
.def_readonly("rtt", &peer_info::rtt)
|
||||
;
|
||||
|
||||
// flags
|
||||
pi.attr("interesting") = (int)peer_info::interesting;
|
||||
pi.attr("choked") = (int)peer_info::choked;
|
||||
pi.attr("remote_interested") = (int)peer_info::remote_interested;
|
||||
|
@ -69,13 +103,21 @@ void bind_peer_info()
|
|||
pi.attr("plaintext_encrypted") = (int)peer_info::plaintext_encrypted;
|
||||
#endif
|
||||
|
||||
pi.attr("standard_bittorrent") = 0;
|
||||
pi.attr("web_seed") = 1;
|
||||
// connection_type
|
||||
pi.attr("standard_bittorrent") = (int)peer_info::standard_bittorrent;
|
||||
pi.attr("web_seed") = (int)peer_info::web_seed;
|
||||
|
||||
pi.attr("tracker") = 0x1;
|
||||
pi.attr("dht") = 0x2;
|
||||
pi.attr("pex") = 0x4;
|
||||
pi.attr("lsd") = 0x8;
|
||||
pi.attr("resume_data") = 0x10;
|
||||
// source
|
||||
pi.attr("tracker") = (int)peer_info::tracker;
|
||||
pi.attr("dht") = (int)peer_info::dht;
|
||||
pi.attr("pex") = (int)peer_info::pex;
|
||||
pi.attr("lsd") = (int)peer_info::lsd;
|
||||
pi.attr("resume_data") = (int)peer_info::resume_data;
|
||||
|
||||
// read/write state
|
||||
pi.attr("bw_idle") = (int)peer_info::bw_idle;
|
||||
pi.attr("bw_torrent") = (int)peer_info::bw_torrent;
|
||||
pi.attr("bw_global") = (int)peer_info::bw_global;
|
||||
pi.attr("bw_network") = (int)peer_info::bw_network;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue