[libcalamares] Add output to CalledProcessError
- Refactor, internal _handle_check_target_env_call_error doesn't need to be in header or visible. - Add optional output (of the command) to the Python exception.
This commit is contained in:
parent
1f3f6111f7
commit
f5aec1ad8a
@ -36,6 +36,24 @@
|
|||||||
|
|
||||||
namespace bp = boost::python;
|
namespace bp = boost::python;
|
||||||
|
|
||||||
|
static int
|
||||||
|
_handle_check_target_env_call_error( int ec, const QString& cmd, const QString& output = QString() )
|
||||||
|
{
|
||||||
|
if ( !ec )
|
||||||
|
return ec;
|
||||||
|
|
||||||
|
QString raise = QString( "import subprocess\n"
|
||||||
|
"e = subprocess.CalledProcessError(%1,\"%2\")\n" )
|
||||||
|
.arg( ec )
|
||||||
|
.arg( cmd );
|
||||||
|
if ( !output.isEmpty() )
|
||||||
|
raise.append( QStringLiteral("e.output = \"\"\"%1\"\"\"\n").arg( output ) );
|
||||||
|
raise.append("raise e");
|
||||||
|
bp::exec( raise.toStdString().c_str() );
|
||||||
|
bp::throw_error_already_set();
|
||||||
|
return ec;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CalamaresPython
|
namespace CalamaresPython
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -156,23 +174,6 @@ check_target_env_output( const bp::list& args,
|
|||||||
return output.toStdString();
|
return output.toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
_handle_check_target_env_call_error( int ec, const QString& cmd )
|
|
||||||
{
|
|
||||||
if ( !ec )
|
|
||||||
return ec;
|
|
||||||
|
|
||||||
QString raise = QString( "import subprocess\n"
|
|
||||||
"raise subprocess.CalledProcessError(%1,\"%2\")" )
|
|
||||||
.arg( ec )
|
|
||||||
.arg( cmd );
|
|
||||||
bp::exec( raise.toStdString().c_str() );
|
|
||||||
bp::throw_error_already_set();
|
|
||||||
return ec;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
debug( const std::string& s )
|
debug( const std::string& s )
|
||||||
{
|
{
|
||||||
|
@ -67,8 +67,6 @@ boost::python::list gettext_languages();
|
|||||||
|
|
||||||
void debug( const std::string& s );
|
void debug( const std::string& s );
|
||||||
|
|
||||||
inline int _handle_check_target_env_call_error( int ec, const QString& cmd );
|
|
||||||
|
|
||||||
class PythonJobInterface
|
class PythonJobInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user