diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index 201f56a15..56a616ea2 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -36,6 +36,11 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_output_list_overloads, CalamaresPython::check_target_env_output, 1, 3 ); +BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( target_env_output_overloads, + target_env_output, + 2, + 4 ); + BOOST_PYTHON_MODULE( libcalamares ) { bp::object package = bp::scope(); @@ -56,7 +61,11 @@ BOOST_PYTHON_MODULE( libcalamares ) &CalamaresPython::PythonJobInterface::setprogress, bp::args( "progress" ), "Reports the progress status of this job to Calamares, " - "as a real number between 0 and 1." ); + "as a real number between 0 and 1." ) + .def( "target_env_output", + &CalamaresPython::PythonJobInterface::target_env_output, + target_env_output_overloads( bp::args( "args", "callback", "stdin", "timeout" ), "docstring")) + ; bp::class_< CalamaresPython::GlobalStoragePythonWrapper >( "GlobalStorage", bp::init< Calamares::GlobalStorage* >() ) diff --git a/src/libcalamares/PythonJobApi.cpp b/src/libcalamares/PythonJobApi.cpp index 480a115ae..16b6e523a 100644 --- a/src/libcalamares/PythonJobApi.cpp +++ b/src/libcalamares/PythonJobApi.cpp @@ -171,6 +171,13 @@ PythonJobInterface::setprogress( qreal progress ) } } +int +PythonJobInterface::target_env_output( const boost::python::list& args, const std::string& callback, const std::string& stdin, int timeout ) +{ + cWarning() << "target env" << _bp_list_to_qstringlist(args) << "cb" << callback.c_str() << "stdin" << stdin.c_str() << "timeout" << timeout; + return 0; +} + std::string obscure( const std::string& string ) { diff --git a/src/libcalamares/PythonJobApi.h b/src/libcalamares/PythonJobApi.h index 3c7977c4f..a1597ad98 100644 --- a/src/libcalamares/PythonJobApi.h +++ b/src/libcalamares/PythonJobApi.h @@ -63,6 +63,12 @@ public: boost::python::dict configuration; void setprogress( qreal progress ); + /** @brief Run the command @p args and process lines of output + * + * Calls the function @p callback from the job module on each + * line of output. Returns the exit code of the command. + */ + int target_env_output( const boost::python::list& args, const std::string& callback, const std::string& stdin = std::string(), int timeout = 10 ); private: Calamares::PythonJob* m_parent;