Added more informative tracker status display.

This commit is contained in:
Alex Dedul 2007-07-19 19:33:49 +00:00
parent f486ea3dc1
commit 7787a6cf0c
3 changed files with 30 additions and 22 deletions

View File

@ -49,6 +49,7 @@
import pickle
import os
import re
import shutil
import statvfs
import time
@ -583,23 +584,24 @@ class Manager:
self.save_fastresume_data(event['unique_ID'])
elif event['event_type'] is self.constants['EVENT_TRACKER']:
unique_ID = event['unique_ID']
status = event['tracker_status']
message = event['message']
tracker = message[message.find('"')+1:message.rfind('"')]
tracker_status = event['tracker_status']
if tracker_status == "Alert":
match = re.search('tracker:\s*".*"\s*(.*)',
event["message"])
message = match and match.groups()[0] or ""
tracker_status += \
": %s (HTTP code=%s, times in a row=%s)" % \
(message, event["status_code"],
event["times_in_row"])
elif tracker_status == "Warning":
# Probably will need proper formatting later, not
# tested
tracker_status += ': %s' % event["message"]
self.set_supp_torrent_state_val(unique_ID, "tracker_status",
(tracker, status))
old_state = self.get_supp_torrent_state(unique_ID)
try:
new = old_state['tracker_messages']
except KeyError:
new = {}
new[tracker] = message
self.set_supp_torrent_state_val(unique_ID, "tracker_messages",
new)
tracker_status)
return ret

View File

@ -697,7 +697,7 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args)
total_peers = s.num_incomplete != -1? s.num_incomplete : connected_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: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}",
"name", t.handle.get_torrent_info().name().c_str(),
"num_files", t.handle.get_torrent_info().num_files(),
"state", s.state,
@ -708,7 +708,6 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args)
"upload_rate", s.upload_rate,
"total_download", s.total_download,
"total_upload", s.total_upload,
"tracker_ok", !s.current_tracker.empty(),
"next_announce", boost::posix_time::to_simple_string(s.next_announce).c_str(),
"tracker", s.current_tracker.c_str(),
"progress", s.progress,
@ -855,13 +854,17 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
long index = get_torrent_index(handle);
if (PyErr_Occurred())
return NULL;
int status_code = (dynamic_cast<tracker_alert*>(popped_alert))->status_code;
int times_in_row = (dynamic_cast<tracker_alert*>(popped_alert))->times_in_row;
if (handle_exists(handle))
return Py_BuildValue("{s:i,s:i,s:s,s:s}",
return Py_BuildValue("{s:i,s:i,s:s,s:i,s:i,s:s}",
"event_type", EVENT_TRACKER,
"unique_ID",
M_torrents->at(index).unique_ID,
"tracker_status", "Bad response (status code=?)",
"tracker_status", "Alert",
"status_code", status_code,
"times_in_row", times_in_row,
"message", a->msg().c_str());
else
{ Py_INCREF(Py_None); return Py_None; }
@ -891,7 +894,7 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
"event_type", EVENT_TRACKER,
"unique_ID",
M_torrents->at(index).unique_ID,
"tracker_status", "Announce succeeded",
"tracker_status", "Announce OK",
"message", a->msg().c_str());
else
{ Py_INCREF(Py_None); return Py_None; }
@ -907,7 +910,7 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
"event_type", EVENT_TRACKER,
"unique_ID",
M_torrents->at(index).unique_ID,
"tracker_status", "Warning in response",
"tracker_status", "Warning",
"message", a->msg().c_str());
else
{ Py_INCREF(Py_None); return Py_None; }

View File

@ -982,7 +982,10 @@ class DelugeGTK:
self.wtree.get_widget("progressbar").set_text(common.fpcnt(state["progress"]))
self.text_summary_share_ratio.set_text('%.3f'%(self.calc_share_ratio(unique_id, state)))
self.text_summary_tracker.set_text(str(state["tracker"]))
self.text_summary_tracker_status.set_text(str(state["tracker_ok"]))
# At this time we still may not receive EVENT_TRACKER so there
# could be no tracker_status yet.
if "tracker_status" in state:
self.text_summary_tracker_status.set_text(state["tracker_status"])
self.text_summary_next_announce.set_text(str(state["next_announce"]))
self.text_summary_eta.set_text(common.estimate_eta(state))
elif page_num == 1: # Peers