2018-08-30 02:38:13 +08:00
|
|
|
/*
|
|
|
|
* ioredirect.cpp
|
|
|
|
*
|
|
|
|
* Created on: 2018年8月27日
|
|
|
|
* Author: fasiondog
|
|
|
|
*/
|
|
|
|
|
2023-12-26 18:25:50 +08:00
|
|
|
#include <pybind11/pybind11.h>
|
2018-08-30 02:38:13 +08:00
|
|
|
#include "ioredirect.h"
|
|
|
|
|
2023-12-26 18:25:50 +08:00
|
|
|
namespace py = pybind11;
|
2018-08-30 02:38:13 +08:00
|
|
|
|
2023-12-26 18:25:50 +08:00
|
|
|
void export_io_redirect(py::module& m) {
|
|
|
|
py::class_<OstreamRedirect>(m, "OstreamRedirect")
|
|
|
|
.def(py::init<bool, bool>(), py::arg("stdout") = true, py::arg("stderr") = true)
|
2020-06-25 15:59:37 +08:00
|
|
|
.def("__enter__", &OstreamRedirect::enter)
|
|
|
|
.def("__exit__", &OstreamRedirect::exit)
|
|
|
|
.def("open", &OstreamRedirect::enter)
|
|
|
|
.def("close", &OstreamRedirect::exit);
|
2018-08-30 02:38:13 +08:00
|
|
|
}
|