fixes get_download_queue in python binding

This commit is contained in:
Arvid Norberg 2007-04-19 17:56:12 +00:00
parent 219db47776
commit 05714ab5aa
3 changed files with 21 additions and 14 deletions

View File

@ -153,17 +153,17 @@ def print_download_queue(console, download_queue):
for e in download_queue:
out += '%4d: [' % e['piece_index'];
finished_blocks = e['finished_blocks']
requested_blocks = e['requested_blocks']
for index in xrange(len(e['peers']))
if (finished_blocks[index])
for fin, req in zip(e['finished_blocks'], e['requested_blocks']):
if fin:
out += '#'
elif requested_blocks[index]
elif req:
out += '+'
else
else:
out += '-'
out += ']\n'
write_line(console, out)
def main():
from optparse import OptionParser
@ -220,8 +220,8 @@ def main():
ses.listen_on(options.port, options.port + 10)
ses.set_settings(settings)
ses.set_severity_level(lt.alert.severity_levels.info)
ses.add_extension(lt.create_ut_pex_plugin);
ses.add_extension(lt.create_metadata_plugin);
# ses.add_extension(lt.create_ut_pex_plugin);
# ses.add_extension(lt.create_metadata_plugin);
handles = []
alerts = []

View File

@ -33,6 +33,7 @@ void bind_peer_info()
.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)
;
pi.attr("interesting") = (int)peer_info::interesting;
@ -47,5 +48,11 @@ void bind_peer_info()
pi.attr("standard_bittorrent") = 0;
pi.attr("web_seed") = 1;
pi.attr("tracker") = 0x1;
pi.attr("dht") = 0x2;
pi.attr("pex") = 0x4;
pi.attr("lsd") = 0x8;
pi.attr("resume_data") = 0x10;
}

View File

@ -103,18 +103,18 @@ list get_download_queue(torrent_handle& handle)
partial_piece["blocks_in_piece"] = i->blocks_in_piece;
list requested;
list finished;
list peer;
// list peer;
for (int k = 0; k < i->blocks_in_piece; ++k)
{
requested.extend(i->requested_blocks[k]);
finished.extend(i->finished_blocks[k]);
peer.extend(i->peer[k]);
requested.append(bool(i->requested_blocks[k]));
finished.append(bool(i->finished_blocks[k]));
// peer.append(i->peer[k]);
}
partial_piece["requested_blocks"] = requested;
partial_piece["finished_blocks"] = finished;
partial_piece["peer"] = peer;
// partial_piece["peer"] = peer;
ret.extend(partial_piece);
ret.append(partial_piece);
}
return ret;