exposed alert error_codes to python

This commit is contained in:
Arvid Norberg 2011-06-25 20:11:31 +00:00
parent b94d6ddbfa
commit abb015e3de
5 changed files with 64 additions and 2 deletions

View File

@ -87,6 +87,7 @@
incoming connection
* added more detailed instrumentation of the disk I/O thread
* exposed alert error_codes to python
* fixed bug in announce_entry::next_announce_in and min_announce_in
* fixed sign issue in set_alert_mask signature
* fixed unaligned disk access for unbuffered I/O in windows

View File

@ -54,6 +54,7 @@ python-extension libtorrent
src/peer_info.cpp
src/ip_filter.cpp
src/magnet_uri.cpp
src/error_code.cpp
: <include>src
<library>/torrent//torrent/<link>static
<boost>system:<library>boost_python

View File

@ -116,6 +116,7 @@ void bind_alert()
.def_readonly("msg", &tracker_error_alert::msg)
.def_readonly("times_in_row", &tracker_error_alert::times_in_row)
.def_readonly("status_code", &tracker_error_alert::status_code)
.def_readonly("error", &tracker_error_alert::error)
;
class_<tracker_warning_alert, bases<tracker_alert>, noncopyable>(
@ -140,7 +141,9 @@ void bind_alert()
"peer_ban_alert", no_init);
class_<peer_error_alert, bases<peer_alert>, noncopyable>(
"peer_error_alert", no_init);
"peer_error_alert", no_init)
.def_readonly("error", &peer_error_alert::error)
;
class_<invalid_request_alert, bases<peer_alert>, noncopyable>(
"invalid_request_alert", no_init)
@ -205,6 +208,7 @@ void bind_alert()
class_<file_error_alert, bases<torrent_alert>, noncopyable>(
"file_error_alert", no_init)
.def_readonly("file", &file_error_alert::file)
.def_readonly("error", &file_error_alert::error)
#ifndef TORRENT_NO_DEPRECATE
.def_readonly("msg", &file_error_alert::msg)
#endif
@ -231,6 +235,7 @@ void bind_alert()
"portmap_error_alert", no_init)
.def_readonly("mapping", &portmap_error_alert::mapping)
.def_readonly("map_type", &portmap_error_alert::map_type)
.def_readonly("error", &portmap_error_alert::error)
#ifndef TORRENT_NO_DEPRECATE
.def_readonly("type", &portmap_error_alert::map_type)
.def_readonly("msg", &portmap_error_alert::msg)
@ -258,6 +263,7 @@ void bind_alert()
class_<fastresume_rejected_alert, bases<torrent_alert>, noncopyable>(
"fastresume_rejected_alert", no_init)
.def_readonly("error", &fastresume_rejected_alert::error)
#ifndef TORRENT_NO_DEPRECATE
.def_readonly("msg", &fastresume_rejected_alert::msg)
#endif
@ -275,7 +281,8 @@ void bind_alert()
;
class_<scrape_failed_alert, bases<tracker_alert>, noncopyable>(
"scrape_failed_alert", no_init);
"scrape_failed_alert", no_init)
;
class_<udp_error_alert, bases<alert>, noncopyable>(
"udp_error_alert", no_init)
@ -352,6 +359,7 @@ void bind_alert()
class_<peer_disconnected_alert, bases<peer_alert>, noncopyable>(
"peer_disconnected_alert", no_init)
.def_readonly("error", &peer_disconnected_alert::error)
#ifndef TORRENT_NO_DEPRECATE
.def_readonly("msg", &peer_disconnected_alert::msg)
#endif
@ -380,6 +388,7 @@ void bind_alert()
#ifndef TORRENT_NO_DEPRECATE
.def_readonly("msg", &torrent_delete_failed_alert::msg)
#endif
.def_readonly("error", &torrent_delete_failed_alert::error)
;
class_<save_resume_data_failed_alert, bases<torrent_alert>, noncopyable>(
@ -387,6 +396,7 @@ void bind_alert()
#ifndef TORRENT_NO_DEPRECATE
.def_readonly("msg", &save_resume_data_failed_alert::msg)
#endif
.def_readonly("error", &save_resume_data_failed_alert::error)
;
class_<performance_alert, bases<torrent_alert>, noncopyable>(

View File

@ -0,0 +1,48 @@
/*
Copyright (c) 2011, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include <boost/python.hpp>
#include <libtorrent/error_code.hpp>
using namespace boost::python;
using namespace libtorrent;
void bind_error_code()
{
class_<error_code>("error_code")
.def(init<>())
.def("message", &error_code::message)
.def("value", &error_code::value)
.def("clear", &error_code::clear)
;
}

View File

@ -24,12 +24,14 @@ void bind_ip_filter();
void bind_magnet_uri();
void bind_converters();
void bind_create_torrent();
void bind_error_code();
BOOST_PYTHON_MODULE(libtorrent)
{
Py_Initialize();
PyEval_InitThreads();
bind_error_code();
bind_utility();
bind_fingerprint();
bind_big_number();