[shellprocess] Implement timeout setting

- For both shellprocess and contextualprocess, add a top-level key
   "timeout" that defaults to 10 seconds (which it already did).
 - Allows setting "global" timeout for command-lists, while still
   allowing individual timeouts per-command.
 - Setting timeout per global variable in contextualprocess is not
   supported; that would restrict the possible space of comparisions,
   while not supporting a global setting timeout seems reasonable enough.
   Use instances if you need wildly variable timeouts and don't want to
   set them individually.
This commit is contained in:
Adriaan de Groot 2018-01-29 22:08:12 +01:00
parent 2da430fa36
commit c2aca1f5c6
7 changed files with 31 additions and 16 deletions

View file

@ -34,7 +34,6 @@
ShellProcessJob::ShellProcessJob( QObject* parent )
: Calamares::CppJob( parent )
, m_commands( nullptr )
, m_dontChroot( false )
{
}
@ -70,11 +69,14 @@ ShellProcessJob::exec()
void
ShellProcessJob::setConfigurationMap( const QVariantMap& configurationMap )
{
m_dontChroot = CalamaresUtils::getBool( configurationMap, "dontChroot", false );
bool dontChroot = CalamaresUtils::getBool( configurationMap, "dontChroot", false );
int timeout = CalamaresUtils::getInteger( configurationMap, "timeout", 10 );
if ( timeout < 1 )
timeout = 10;
if ( configurationMap.contains( "script" ) )
{
m_commands = new CalamaresUtils::CommandList( configurationMap.value( "script" ), !m_dontChroot );
m_commands = new CalamaresUtils::CommandList( configurationMap.value( "script" ), !dontChroot, timeout );
if ( m_commands->isEmpty() )
cDebug() << "ShellProcessJob: \"script\" contains no commands for" << moduleInstanceKey();
}