Added event for each tracker alert we are intrested in and some tracker

status messages i18n tweaks.
This commit is contained in:
Alex Dedul 2007-07-19 21:14:30 +00:00
parent 31407d0231
commit 1f6d182f76
3 changed files with 45 additions and 44 deletions

View File

@ -582,25 +582,32 @@ class Manager:
# save fast resume once torrent finishes so as to not recheck # save fast resume once torrent finishes so as to not recheck
# seed if client crashes # seed if client crashes
self.save_fastresume_data(event['unique_ID']) self.save_fastresume_data(event['unique_ID'])
elif event['event_type'] is self.constants['EVENT_TRACKER']: elif event['event_type'] is self.constants['EVENT_TRACKER_ANNOUNCE']:
unique_ID = event['unique_ID'] self.set_supp_torrent_state_val(event['unique_ID'],
tracker_status = event['tracker_status'] "tracker_status",
N_("Announce sent"))
elif event['event_type'] is self.constants['EVENT_TRACKER_REPLY']:
self.set_supp_torrent_state_val(event['unique_ID'],
"tracker_status",
N_("Announce OK"))
elif event['event_type'] is self.constants['EVENT_TRACKER_ALERT']:
match = re.search('tracker:\s*".*"\s*(.*)', event["message"])
message = match and match.groups()[0] or ""
if tracker_status == "Alert": tracker_status = "%s: %s (%s=%s, %s=%s)" % \
match = re.search('tracker:\s*".*"\s*(.*)', (N_("Alert"), message,
event["message"]) N_("HTTP code"), event["status_code"],
message = match and match.groups()[0] or "" N_("times in a row"), event["times_in_row"])
tracker_status += \ self.set_supp_torrent_state_val(event['unique_ID'],
": %s (HTTP code=%s, times in a row=%s)" % \ "tracker_status",
(message, event["status_code"], tracker_status)
event["times_in_row"]) elif event['event_type'] is self.constants['EVENT_TRACKER_WARNING']:
elif tracker_status == "Warning": # Probably will need proper formatting later, not tested yet
# Probably will need proper formatting later, not tracker_status = '%s: %s' % (N_("Warning", event["message"]))
# tested
tracker_status += ': %s' % event["message"]
self.set_supp_torrent_state_val(unique_ID, "tracker_status", self.set_supp_torrent_state_val(event['unique_ID'],
"tracker_status",
tracker_status) tracker_status)
return ret return ret

View File

@ -76,9 +76,12 @@ using namespace libtorrent;
#define EVENT_HASH_FAILED_ERROR 5 #define EVENT_HASH_FAILED_ERROR 5
#define EVENT_PEER_BAN_ERROR 6 #define EVENT_PEER_BAN_ERROR 6
#define EVENT_FASTRESUME_REJECTED_ERROR 8 #define EVENT_FASTRESUME_REJECTED_ERROR 8
#define EVENT_TRACKER 9 #define EVENT_TRACKER_ANNOUNCE 9
#define EVENT_OTHER 10 #define EVENT_TRACKER_REPLY 10
#define EVENT_STORAGE_MOVED 11 #define EVENT_TRACKER_ALERT 11
#define EVENT_TRACKER_WARNING 12
#define EVENT_OTHER 13
#define EVENT_STORAGE_MOVED 14
#define STATE_QUEUED 0 #define STATE_QUEUED 0
@ -356,7 +359,7 @@ static PyObject *torrent_init(PyObject *self, PyObject *args)
M_ses->add_extension(&libtorrent::create_metadata_plugin); M_ses->add_extension(&libtorrent::create_metadata_plugin);
M_constants = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}", M_constants = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}",
"EVENT_NULL", EVENT_NULL, "EVENT_NULL", EVENT_NULL,
"EVENT_FINISHED", EVENT_FINISHED, "EVENT_FINISHED", EVENT_FINISHED,
"EVENT_PEER_ERROR", EVENT_PEER_ERROR, "EVENT_PEER_ERROR", EVENT_PEER_ERROR,
@ -365,7 +368,10 @@ static PyObject *torrent_init(PyObject *self, PyObject *args)
"EVENT_HASH_FAILED_ERROR", EVENT_HASH_FAILED_ERROR, "EVENT_HASH_FAILED_ERROR", EVENT_HASH_FAILED_ERROR,
"EVENT_PEER_BAN_ERROR", EVENT_PEER_BAN_ERROR, "EVENT_PEER_BAN_ERROR", EVENT_PEER_BAN_ERROR,
"EVENT_FASTRESUME_REJECTED_ERROR", EVENT_FASTRESUME_REJECTED_ERROR, "EVENT_FASTRESUME_REJECTED_ERROR", EVENT_FASTRESUME_REJECTED_ERROR,
"EVENT_TRACKER", EVENT_TRACKER, "EVENT_TRACKER_ANNOUNCE", EVENT_TRACKER_ANNOUNCE,
"EVENT_TRACKER_REPLY", EVENT_TRACKER_REPLY,
"EVENT_TRACKER_ALERT", EVENT_TRACKER_ALERT,
"EVENT_TRACKER_WARNING", EVENT_TRACKER_WARNING,
"EVENT_OTHER", EVENT_OTHER, "EVENT_OTHER", EVENT_OTHER,
"EVENT_STORAGE_MOVED", EVENT_STORAGE_MOVED, "EVENT_STORAGE_MOVED", EVENT_STORAGE_MOVED,
"STATE_QUEUED", STATE_QUEUED, "STATE_QUEUED", STATE_QUEUED,
@ -840,11 +846,10 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
return NULL; return NULL;
if (handle_exists(handle)) if (handle_exists(handle))
return Py_BuildValue("{s:i,s:i,s:s,s:s}", return Py_BuildValue("{s:i,s:i,s:s}",
"event_type", EVENT_TRACKER, "event_type", EVENT_TRACKER_ANNOUNCE,
"unique_ID", "unique_ID",
M_torrents->at(index).unique_ID, M_torrents->at(index).unique_ID,
"tracker_status", "Announce sent",
"message", a->msg().c_str()); "message", a->msg().c_str());
else else
{ Py_INCREF(Py_None); return Py_None; } { Py_INCREF(Py_None); return Py_None; }
@ -858,11 +863,10 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
int times_in_row = (dynamic_cast<tracker_alert*>(popped_alert))->times_in_row; int times_in_row = (dynamic_cast<tracker_alert*>(popped_alert))->times_in_row;
if (handle_exists(handle)) if (handle_exists(handle))
return Py_BuildValue("{s:i,s:i,s:s,s:i,s:i,s:s}", return Py_BuildValue("{s:i,s:i,s:i,s:i,s:s}",
"event_type", EVENT_TRACKER, "event_type", EVENT_TRACKER_ALERT,
"unique_ID", "unique_ID",
M_torrents->at(index).unique_ID, M_torrents->at(index).unique_ID,
"tracker_status", "Alert",
"status_code", status_code, "status_code", status_code,
"times_in_row", times_in_row, "times_in_row", times_in_row,
"message", a->msg().c_str()); "message", a->msg().c_str());
@ -890,11 +894,10 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
return NULL; return NULL;
if (handle_exists(handle)) if (handle_exists(handle))
return Py_BuildValue("{s:i,s:i,s:s,s:s}", return Py_BuildValue("{s:i,s:i,s:s}",
"event_type", EVENT_TRACKER, "event_type", EVENT_TRACKER_REPLY,
"unique_ID", "unique_ID",
M_torrents->at(index).unique_ID, M_torrents->at(index).unique_ID,
"tracker_status", "Announce OK",
"message", a->msg().c_str()); "message", a->msg().c_str());
else else
{ Py_INCREF(Py_None); return Py_None; } { Py_INCREF(Py_None); return Py_None; }
@ -906,11 +909,10 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
return NULL; return NULL;
if (handle_exists(handle)) if (handle_exists(handle))
return Py_BuildValue("{s:i,s:i,s:s,s:s}", return Py_BuildValue("{s:i,s:i,s:s}",
"event_type", EVENT_TRACKER, "event_type", EVENT_TRACKER_WARNING,
"unique_ID", "unique_ID",
M_torrents->at(index).unique_ID, M_torrents->at(index).unique_ID,
"tracker_status", "Warning",
"message", a->msg().c_str()); "message", a->msg().c_str());
else else
{ Py_INCREF(Py_None); return Py_None; } { Py_INCREF(Py_None); return Py_None; }

View File

@ -985,15 +985,7 @@ class DelugeGTK:
# At this time we still may not receive EVENT_TRACKER so there # At this time we still may not receive EVENT_TRACKER so there
# could be no tracker_status yet. # could be no tracker_status yet.
if "tracker_status" in state: if "tracker_status" in state:
if(state["tracker_status"] == "Announce OK"): self.text_summary_tracker_status.set_text(state["tracker_status"])
self.text_summary_tracker_status.set_text(_("Announce OK"))
elif(state["tracker_status"] == "Warning"):
self.text_summary_tracker_status.set_text(_("Warning"))
elif(state["tracker_status"] == "Announce sent"):
self.text_summary_tracker_status.set_text(_("Announce sent"))
elif(state["tracker_status"] == "Alert"):
self.text_summary_tracker_status.set_text(_("Alert"))
self.text_summary_next_announce.set_text(str(state["next_announce"])) self.text_summary_next_announce.set_text(str(state["next_announce"]))
self.text_summary_eta.set_text(common.estimate_eta(state)) self.text_summary_eta.set_text(common.estimate_eta(state))
elif page_num == 1: # Peers elif page_num == 1: # Peers