[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,
|
||||
1,
|
||||
3 );
|
||||
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( target_env_output_overloads,
|
||||
target_env_output,
|
||||
2,
|
||||
4 );
|
||||
|
||||
BOOST_PYTHON_MODULE( libcalamares )
|
||||
{
|
||||
@ -61,11 +57,7 @@ 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." )
|
||||
.def( "target_env_output",
|
||||
&CalamaresPython::PythonJobInterface::target_env_output,
|
||||
target_env_output_overloads( bp::args( "args", "callback", "stdin", "timeout" ), "docstring"))
|
||||
;
|
||||
"as a real number between 0 and 1." );
|
||||
|
||||
bp::class_< CalamaresPython::GlobalStoragePythonWrapper >( "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"
|
||||
"Returns the program's standard output, and raises a "
|
||||
"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",
|
||||
&CalamaresPython::obscure,
|
||||
bp::args( "s" ),
|
||||
|
@ -172,9 +172,10 @@ PythonJobInterface::setprogress( qreal progress )
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ check_target_env_output( const std::string& command, const std::string& stdin =
|
||||
std::string
|
||||
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 );
|
||||
|
||||
boost::python::object gettext_path();
|
||||
@ -63,12 +65,6 @@ 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;
|
||||
|
Loading…
Reference in New Issue
Block a user