[libcalamares] Don't use reserved identifiers

This commit is contained in:
Adriaan de Groot 2022-02-07 12:51:22 +01:00
parent 660b198da0
commit ebdcb15703

View File

@ -28,7 +28,7 @@
namespace bp = boost::python; namespace bp = boost::python;
static int static int
_handle_check_target_env_call_error( const CalamaresUtils::ProcessResult& ec, const QString& cmd ) handle_check_target_env_call_error( const CalamaresUtils::ProcessResult& ec, const QString& cmd )
{ {
if ( !ec.first ) if ( !ec.first )
{ {
@ -49,6 +49,26 @@ _handle_check_target_env_call_error( const CalamaresUtils::ProcessResult& ec, co
return ec.first; return ec.first;
} }
static inline QStringList
bp_list_to_qstringlist( const bp::list& args )
{
QStringList list;
for ( int i = 0; i < bp::len( args ); ++i )
{
list.append( QString::fromStdString( bp::extract< std::string >( args[ i ] ) ) );
}
return list;
}
static inline CalamaresUtils::ProcessResult
target_env_command( const QStringList& args, const std::string& stdin, int timeout )
{
// Since Python doesn't give us the type system for distinguishing
// seconds from other integral types, massage to seconds here.
return CalamaresUtils::System::instance()->targetEnvCommand(
args, QString(), QString::fromStdString( stdin ), std::chrono::seconds( timeout ) );
}
namespace CalamaresPython namespace CalamaresPython
{ {
@ -64,68 +84,47 @@ mount( const std::string& device_path,
QString::fromStdString( options ) ); QString::fromStdString( options ) );
} }
static inline QStringList
_bp_list_to_qstringlist( const bp::list& args )
{
QStringList list;
for ( int i = 0; i < bp::len( args ); ++i )
{
list.append( QString::fromStdString( bp::extract< std::string >( args[ i ] ) ) );
}
return list;
}
static inline CalamaresUtils::ProcessResult
_target_env_command( const QStringList& args, const std::string& stdin, int timeout )
{
// Since Python doesn't give us the type system for distinguishing
// seconds from other integral types, massage to seconds here.
return CalamaresUtils::System::instance()->targetEnvCommand(
args, QString(), QString::fromStdString( stdin ), std::chrono::seconds( timeout ) );
}
int int
target_env_call( const std::string& command, const std::string& stdin, int timeout ) target_env_call( const std::string& command, const std::string& stdin, int timeout )
{ {
return _target_env_command( QStringList { QString::fromStdString( command ) }, stdin, timeout ).first; return target_env_command( QStringList { QString::fromStdString( command ) }, stdin, timeout ).first;
} }
int int
target_env_call( const bp::list& args, const std::string& stdin, int timeout ) target_env_call( const bp::list& args, const std::string& stdin, int timeout )
{ {
return _target_env_command( _bp_list_to_qstringlist( args ), stdin, timeout ).first; return target_env_command( bp_list_to_qstringlist( args ), stdin, timeout ).first;
} }
int int
check_target_env_call( const std::string& command, const std::string& stdin, int timeout ) check_target_env_call( const std::string& command, const std::string& stdin, int timeout )
{ {
auto ec = _target_env_command( QStringList { QString::fromStdString( command ) }, stdin, timeout ); auto ec = target_env_command( QStringList { QString::fromStdString( command ) }, stdin, timeout );
return _handle_check_target_env_call_error( ec, QString::fromStdString( command ) ); return handle_check_target_env_call_error( ec, QString::fromStdString( command ) );
} }
int int
check_target_env_call( const bp::list& args, const std::string& stdin, int timeout ) check_target_env_call( const bp::list& args, const std::string& stdin, int timeout )
{ {
auto ec = _target_env_command( _bp_list_to_qstringlist( args ), stdin, timeout ); auto ec = target_env_command( bp_list_to_qstringlist( args ), stdin, timeout );
if ( !ec.first ) if ( !ec.first )
{ {
return ec.first; return ec.first;
} }
QStringList failedCmdList = _bp_list_to_qstringlist( args ); QStringList failedCmdList = bp_list_to_qstringlist( args );
return _handle_check_target_env_call_error( ec, failedCmdList.join( ' ' ) ); return handle_check_target_env_call_error( ec, failedCmdList.join( ' ' ) );
} }
std::string std::string
check_target_env_output( const std::string& command, const std::string& stdin, int timeout ) check_target_env_output( const std::string& command, const std::string& stdin, int timeout )
{ {
auto ec = _target_env_command( QStringList { QString::fromStdString( command ) }, stdin, timeout ); auto ec = target_env_command( QStringList { QString::fromStdString( command ) }, stdin, timeout );
_handle_check_target_env_call_error( ec, QString::fromStdString( command ) ); handle_check_target_env_call_error( ec, QString::fromStdString( command ) );
return ec.second.toStdString(); return ec.second.toStdString();
} }
@ -133,9 +132,9 @@ check_target_env_output( const std::string& command, const std::string& stdin, i
std::string std::string
check_target_env_output( const bp::list& args, const std::string& stdin, int timeout ) check_target_env_output( const bp::list& args, const std::string& stdin, int timeout )
{ {
QStringList list = _bp_list_to_qstringlist( args ); QStringList list = bp_list_to_qstringlist( args );
auto ec = _target_env_command( list, stdin, timeout ); auto ec = target_env_command( list, stdin, timeout );
_handle_check_target_env_call_error( ec, list.join( ' ' ) ); handle_check_target_env_call_error( ec, list.join( ' ' ) );
return ec.second.toStdString(); return ec.second.toStdString();
} }
@ -205,7 +204,7 @@ _process_output( Calamares::Utils::RunLocation location,
const std::string& stdin, const std::string& stdin,
int timeout ) int timeout )
{ {
Calamares::Utils::Runner r( _bp_list_to_qstringlist( args ) ); Calamares::Utils::Runner r( bp_list_to_qstringlist( args ) );
r.setLocation( location ); r.setLocation( location );
if ( !callback.is_none() ) if ( !callback.is_none() )
{ {
@ -236,7 +235,7 @@ _process_output( Calamares::Utils::RunLocation location,
if ( result.getExitCode() ) if ( result.getExitCode() )
{ {
return _handle_check_target_env_call_error( result, r.executable() ); return handle_check_target_env_call_error( result, r.executable() );
} }
return 0; return 0;
} }