Added event for each tracker alert we are intrested in and some tracker
status messages i18n tweaks.
This commit is contained in:
parent
31407d0231
commit
1f6d182f76
43
src/core.py
43
src/core.py
|
@ -582,25 +582,32 @@ class Manager:
|
|||
# save fast resume once torrent finishes so as to not recheck
|
||||
# seed if client crashes
|
||||
self.save_fastresume_data(event['unique_ID'])
|
||||
elif event['event_type'] is self.constants['EVENT_TRACKER']:
|
||||
unique_ID = event['unique_ID']
|
||||
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"]
|
||||
elif event['event_type'] is self.constants['EVENT_TRACKER_ANNOUNCE']:
|
||||
self.set_supp_torrent_state_val(event['unique_ID'],
|
||||
"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 ""
|
||||
|
||||
self.set_supp_torrent_state_val(unique_ID, "tracker_status",
|
||||
tracker_status = "%s: %s (%s=%s, %s=%s)" % \
|
||||
(N_("Alert"), message,
|
||||
N_("HTTP code"), event["status_code"],
|
||||
N_("times in a row"), event["times_in_row"])
|
||||
|
||||
self.set_supp_torrent_state_val(event['unique_ID'],
|
||||
"tracker_status",
|
||||
tracker_status)
|
||||
elif event['event_type'] is self.constants['EVENT_TRACKER_WARNING']:
|
||||
# Probably will need proper formatting later, not tested yet
|
||||
tracker_status = '%s: %s' % (N_("Warning", event["message"]))
|
||||
|
||||
self.set_supp_torrent_state_val(event['unique_ID'],
|
||||
"tracker_status",
|
||||
tracker_status)
|
||||
|
||||
return ret
|
||||
|
|
|
@ -76,9 +76,12 @@ using namespace libtorrent;
|
|||
#define EVENT_HASH_FAILED_ERROR 5
|
||||
#define EVENT_PEER_BAN_ERROR 6
|
||||
#define EVENT_FASTRESUME_REJECTED_ERROR 8
|
||||
#define EVENT_TRACKER 9
|
||||
#define EVENT_OTHER 10
|
||||
#define EVENT_STORAGE_MOVED 11
|
||||
#define EVENT_TRACKER_ANNOUNCE 9
|
||||
#define EVENT_TRACKER_REPLY 10
|
||||
#define EVENT_TRACKER_ALERT 11
|
||||
#define EVENT_TRACKER_WARNING 12
|
||||
#define EVENT_OTHER 13
|
||||
#define EVENT_STORAGE_MOVED 14
|
||||
|
||||
|
||||
#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_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_FINISHED", EVENT_FINISHED,
|
||||
"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_PEER_BAN_ERROR", EVENT_PEER_BAN_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_STORAGE_MOVED", EVENT_STORAGE_MOVED,
|
||||
"STATE_QUEUED", STATE_QUEUED,
|
||||
|
@ -840,11 +846,10 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
if (handle_exists(handle))
|
||||
return Py_BuildValue("{s:i,s:i,s:s,s:s}",
|
||||
"event_type", EVENT_TRACKER,
|
||||
return Py_BuildValue("{s:i,s:i,s:s}",
|
||||
"event_type", EVENT_TRACKER_ANNOUNCE,
|
||||
"unique_ID",
|
||||
M_torrents->at(index).unique_ID,
|
||||
"tracker_status", "Announce sent",
|
||||
"message", a->msg().c_str());
|
||||
else
|
||||
{ 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;
|
||||
|
||||
if (handle_exists(handle))
|
||||
return Py_BuildValue("{s:i,s:i,s:s,s:i,s:i,s:s}",
|
||||
"event_type", EVENT_TRACKER,
|
||||
return Py_BuildValue("{s:i,s:i,s:i,s:i,s:s}",
|
||||
"event_type", EVENT_TRACKER_ALERT,
|
||||
"unique_ID",
|
||||
M_torrents->at(index).unique_ID,
|
||||
"tracker_status", "Alert",
|
||||
"status_code", status_code,
|
||||
"times_in_row", times_in_row,
|
||||
"message", a->msg().c_str());
|
||||
|
@ -890,11 +894,10 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
if (handle_exists(handle))
|
||||
return Py_BuildValue("{s:i,s:i,s:s,s:s}",
|
||||
"event_type", EVENT_TRACKER,
|
||||
return Py_BuildValue("{s:i,s:i,s:s}",
|
||||
"event_type", EVENT_TRACKER_REPLY,
|
||||
"unique_ID",
|
||||
M_torrents->at(index).unique_ID,
|
||||
"tracker_status", "Announce OK",
|
||||
"message", a->msg().c_str());
|
||||
else
|
||||
{ Py_INCREF(Py_None); return Py_None; }
|
||||
|
@ -906,11 +909,10 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
if (handle_exists(handle))
|
||||
return Py_BuildValue("{s:i,s:i,s:s,s:s}",
|
||||
"event_type", EVENT_TRACKER,
|
||||
return Py_BuildValue("{s:i,s:i,s:s}",
|
||||
"event_type", EVENT_TRACKER_WARNING,
|
||||
"unique_ID",
|
||||
M_torrents->at(index).unique_ID,
|
||||
"tracker_status", "Warning",
|
||||
"message", a->msg().c_str());
|
||||
else
|
||||
{ Py_INCREF(Py_None); return Py_None; }
|
||||
|
|
|
@ -985,15 +985,7 @@ class DelugeGTK:
|
|||
# At this time we still may not receive EVENT_TRACKER so there
|
||||
# could be no tracker_status yet.
|
||||
if "tracker_status" in state:
|
||||
if(state["tracker_status"] == "Announce OK"):
|
||||
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_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
|
||||
|
|
Loading…
Reference in New Issue