diff --git a/ChangeLog b/ChangeLog index b1e5fa93e..94679ba1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ + * expose post_dht_stats() to python binding * fix backwards compatibility to downloads without partfiles * improve part-file related error messages * fix reporting &redundant= in tracker announces diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 513e0c1e3..3d4b46645 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -900,6 +900,7 @@ void bind_session() .def("outgoing_ports", &outgoing_ports) #endif .def("post_torrent_updates", allow_threads(<::session::post_torrent_updates), arg("flags") = 0xffffffff) + .def("post_dht_stats", allow_threads(<::session::post_dht_stats)) .def("post_session_stats", allow_threads(<::session::post_session_stats)) .def("is_listening", allow_threads(<::session::is_listening)) .def("listen_port", allow_threads(<::session::listen_port)) diff --git a/bindings/python/test.py b/bindings/python/test.py index 2c42984ba..9cdf146a3 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -383,6 +383,21 @@ class test_session(unittest.TestCase): self.assertTrue(isinstance(a.values, dict)) self.assertTrue(len(a.values) > 0) + def test_post_dht_stats(self): + s = lt.session({'alert_mask': lt.alert.category_t.stats_notification, 'enable_dht': False}) + s.post_dht_stats() + alerts = [] + # first the stats headers log line. but not if logging is disabled + time.sleep(1) + alerts = s.pop_alerts() + a = alerts.pop(0) + while not isinstance(a, lt.dht_stats_alert): + a = alerts.pop(0 +) + self.assertTrue(isinstance(a, lt.dht_stats_alert)) + self.assertTrue(isinstance(a.active_requests, list)) + self.assertTrue(isinstance(a.routing_table, list)) + def test_unknown_settings(self): try: s = lt.session({'unexpected-key-name': 42})