[libcalamares] Move Python callback to utils submodule
- don't need the job to do the callback - allow callable objects from Python - doesn't actually run the process yet
This commit is contained in:
parent
344948b5ab
commit
f2142bc4b3
@ -36,10 +36,6 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_output_list_overloads,
|
|||||||
CalamaresPython::check_target_env_output,
|
CalamaresPython::check_target_env_output,
|
||||||
1,
|
1,
|
||||||
3 );
|
3 );
|
||||||
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( target_env_output_overloads,
|
|
||||||
target_env_output,
|
|
||||||
2,
|
|
||||||
4 );
|
|
||||||
|
|
||||||
BOOST_PYTHON_MODULE( libcalamares )
|
BOOST_PYTHON_MODULE( libcalamares )
|
||||||
{
|
{
|
||||||
@ -61,11 +57,7 @@ BOOST_PYTHON_MODULE( libcalamares )
|
|||||||
&CalamaresPython::PythonJobInterface::setprogress,
|
&CalamaresPython::PythonJobInterface::setprogress,
|
||||||
bp::args( "progress" ),
|
bp::args( "progress" ),
|
||||||
"Reports the progress status of this job to Calamares, "
|
"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::class_< CalamaresPython::GlobalStoragePythonWrapper >( "GlobalStorage",
|
||||||
bp::init< Calamares::GlobalStorage* >() )
|
bp::init< Calamares::GlobalStorage* >() )
|
||||||
@ -146,6 +138,12 @@ BOOST_PYTHON_MODULE( libcalamares )
|
|||||||
"Runs the specified command in the chroot of the target system.\n"
|
"Runs the specified command in the chroot of the target system.\n"
|
||||||
"Returns the program's standard output, and raises a "
|
"Returns the program's standard output, and raises a "
|
||||||
"subprocess.CalledProcessError if something went wrong." ) );
|
"subprocess.CalledProcessError if something went wrong." ) );
|
||||||
|
bp::def( "target_env_process_output",
|
||||||
|
static_cast< int ( * )( const bp::list&, bp::object& ) >( &CalamaresPython::target_env_process_output ),
|
||||||
|
bp::args( "command", "callback" ),
|
||||||
|
"Runs the specified command in the target system, and "
|
||||||
|
"calls the callback function with each line of output." );
|
||||||
|
|
||||||
bp::def( "obscure",
|
bp::def( "obscure",
|
||||||
&CalamaresPython::obscure,
|
&CalamaresPython::obscure,
|
||||||
bp::args( "s" ),
|
bp::args( "s" ),
|
||||||
|
@ -172,9 +172,10 @@ PythonJobInterface::setprogress( qreal progress )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PythonJobInterface::target_env_output( const boost::python::list& args, const std::string& callback, const std::string& stdin, int timeout )
|
target_env_process_output( const boost::python::list& args, boost::python::object& callback )
|
||||||
{
|
{
|
||||||
cWarning() << "target env" << _bp_list_to_qstringlist(args) << "cb" << callback.c_str() << "stdin" << stdin.c_str() << "timeout" << timeout;
|
cWarning() << "target env" << _bp_list_to_qstringlist( args );
|
||||||
|
callback( std::string( "derp" ) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ check_target_env_output( const std::string& command, const std::string& stdin =
|
|||||||
std::string
|
std::string
|
||||||
check_target_env_output( const boost::python::list& args, const std::string& stdin = std::string(), int timeout = 0 );
|
check_target_env_output( const boost::python::list& args, const std::string& stdin = std::string(), int timeout = 0 );
|
||||||
|
|
||||||
|
int target_env_process_output( const boost::python::list& args, boost::python::object& callback );
|
||||||
|
|
||||||
std::string obscure( const std::string& string );
|
std::string obscure( const std::string& string );
|
||||||
|
|
||||||
boost::python::object gettext_path();
|
boost::python::object gettext_path();
|
||||||
@ -63,12 +65,6 @@ public:
|
|||||||
boost::python::dict configuration;
|
boost::python::dict configuration;
|
||||||
|
|
||||||
void setprogress( qreal progress );
|
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:
|
private:
|
||||||
Calamares::PythonJob* m_parent;
|
Calamares::PythonJob* m_parent;
|
||||||
|
Loading…
Reference in New Issue
Block a user