more fixes for the peers/seeds display..

This commit is contained in:
Andrew Resch 2007-06-09 19:43:07 +00:00
parent 9bd479160f
commit e77a3318da
1 changed files with 15 additions and 4 deletions

View File

@ -567,13 +567,13 @@ static PyObject *torrent_pause(PyObject *self, PyObject *args)
python_long unique_ID; python_long unique_ID;
if (!PyArg_ParseTuple(args, "i", &unique_ID)) if (!PyArg_ParseTuple(args, "i", &unique_ID))
return NULL; return NULL;
long index = get_index_from_unique_ID(unique_ID); long index = get_index_from_unique_ID(unique_ID);
if (PyErr_Occurred()) if (PyErr_Occurred())
return NULL; return NULL;
M_torrents->at(index).handle.pause(); M_torrents->at(index).handle.pause();
Py_INCREF(Py_None); return Py_None; Py_INCREF(Py_None); return Py_None;
} }
@ -613,11 +613,20 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args)
long connected_seeds = 0; long connected_seeds = 0;
long connected_peers = 0; long connected_peers = 0;
long total_seeds = 0;
long total_peers = 0;
for (unsigned long i = 0; i < peers.size(); i++) { for (unsigned long i = 0; i < peers.size(); i++) {
if ((peers[i].flags&(peer_info::seed)) && !(peers[i].flags&(peer_info::handshake|peer_info::connecting|peer_info::queued))) if ((peers[i].flags&(peer_info::seed)) && !(peers[i].flags&(peer_info::handshake|peer_info::connecting|peer_info::queued)))
connected_seeds++; connected_seeds++;
if (!(peers[i].flags&(peer_info::handshake|peer_info::connecting|peer_info::queued|peer_info::seed))) if (!(peers[i].flags&(peer_info::handshake|peer_info::connecting|peer_info::queued|peer_info::seed)))
connected_peers++; connected_peers++;
if ((peers[i].flags&(peer_info::seed)))
total_seeds++;
else
total_peers++;
} }
return Py_BuildValue("{s:s,s:i,s:i,s:l,s:l,s:f,s:f,s:f,s:L,s:L,s:b,s:s,s:s,s:f,s:L,s:L,s:l,s:i,s:i,s:L,s:L,s:i,s:l,s:l,s:b,s:b,s:L,s:L,s:L}", return Py_BuildValue("{s:s,s:i,s:i,s:l,s:l,s:f,s:f,s:f,s:L,s:L,s:b,s:s,s:s,s:f,s:L,s:L,s:l,s:i,s:i,s:L,s:L,s:i,s:l,s:l,s:b,s:b,s:L,s:L,s:L}",
@ -643,8 +652,10 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args)
"total_size", i.total_size(), "total_size", i.total_size(),
"piece_length", i.piece_length(), "piece_length", i.piece_length(),
"num_pieces", i.num_pieces(), "num_pieces", i.num_pieces(),
"total_peers", long(s.num_incomplete != -1? s.num_incomplete : connected_peers), // "total_peers", long(s.num_incomplete != -1? s.num_incomplete : connected_peers),
"total_seeds", long(s.num_complete != -1? s.num_complete : connected_seeds), // "total_seeds", long(s.num_complete != -1? s.num_complete : connected_seeds),
"total_peers", total_peers,
"total_seeds", total_seeds,
"is_paused", t.handle.is_paused(), "is_paused", t.handle.is_paused(),
"is_seed", t.handle.is_seed(), "is_seed", t.handle.is_seed(),
"total_done", s.total_done, "total_done", s.total_done,