[libcalamares] Apply current coding style to all of libcalamares/
This commit is contained in:
parent
fa676c573e
commit
1afa9c4d08
@ -24,11 +24,11 @@ namespace Calamares
|
||||
|
||||
CppJob::CppJob( QObject* parent )
|
||||
: Job( parent )
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppJob::~CppJob()
|
||||
{}
|
||||
CppJob::~CppJob() {}
|
||||
|
||||
|
||||
void
|
||||
@ -44,4 +44,4 @@ CppJob::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
Q_UNUSED( configurationMap )
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Calamares
|
||||
|
@ -45,6 +45,6 @@ protected:
|
||||
QString m_instanceKey;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Calamares
|
||||
|
||||
#endif // CALAMARES_CPPJOB_H
|
||||
#endif // CALAMARES_CPPJOB_H
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef DLLEXPORT
|
||||
# if defined (DLLEXPORT_PRO)
|
||||
# define DLLEXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define DLLEXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#if defined( DLLEXPORT_PRO )
|
||||
#define DLLEXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define DLLEXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include "JobQueue.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Yaml.h"
|
||||
#include "utils/Units.h"
|
||||
#include "utils/Yaml.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
@ -40,7 +40,8 @@ namespace bp = boost::python;
|
||||
|
||||
using CalamaresUtils::operator""_MiB;
|
||||
|
||||
namespace Calamares {
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
GlobalStorage::GlobalStorage()
|
||||
: QObject( nullptr )
|
||||
@ -102,13 +103,15 @@ GlobalStorage::debugDump() const
|
||||
}
|
||||
|
||||
bool
|
||||
GlobalStorage::save(const QString& filename)
|
||||
GlobalStorage::save( const QString& filename )
|
||||
{
|
||||
QFile f( filename );
|
||||
if ( !f.open( QFile::WriteOnly ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
f.write( QJsonDocument::fromVariant( m ).toJson() ) ;
|
||||
f.write( QJsonDocument::fromVariant( m ).toJson() );
|
||||
f.close();
|
||||
return true;
|
||||
}
|
||||
@ -118,18 +121,24 @@ GlobalStorage::load( const QString& filename )
|
||||
{
|
||||
QFile f( filename );
|
||||
if ( !f.open( QFile::ReadOnly ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonParseError e;
|
||||
QJsonDocument d = QJsonDocument::fromJson( f.read( 1_MiB ), &e );
|
||||
if ( d.isNull() )
|
||||
{
|
||||
cWarning() << filename << e.errorString();
|
||||
}
|
||||
else if ( !d.isObject() )
|
||||
{
|
||||
cWarning() << filename << "Not suitable JSON.";
|
||||
}
|
||||
else
|
||||
{
|
||||
auto map = d.toVariant().toMap();
|
||||
for( auto i = map.constBegin() ; i != map.constEnd() ; ++i )
|
||||
for ( auto i = map.constBegin(); i != map.constEnd(); ++i )
|
||||
{
|
||||
insert( i.key(), *i );
|
||||
}
|
||||
@ -150,12 +159,14 @@ GlobalStorage::loadYaml( const QString& filename )
|
||||
bool ok = false;
|
||||
auto gs = CalamaresUtils::loadYaml( filename, &ok );
|
||||
if ( ok )
|
||||
{
|
||||
m = gs;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
|
||||
@ -172,7 +183,7 @@ Calamares::GlobalStorage* GlobalStoragePythonWrapper::s_gs_instance = nullptr;
|
||||
GlobalStoragePythonWrapper::GlobalStoragePythonWrapper( Calamares::GlobalStorage* gs )
|
||||
: m_gs( gs ? gs : s_gs_instance )
|
||||
{
|
||||
if (!m_gs)
|
||||
if ( !m_gs )
|
||||
{
|
||||
s_gs_instance = new Calamares::GlobalStorage;
|
||||
m_gs = s_gs_instance;
|
||||
@ -194,11 +205,9 @@ GlobalStoragePythonWrapper::count() const
|
||||
|
||||
|
||||
void
|
||||
GlobalStoragePythonWrapper::insert( const std::string& key,
|
||||
const bp::object& value )
|
||||
GlobalStoragePythonWrapper::insert( const std::string& key, const bp::object& value )
|
||||
{
|
||||
m_gs->insert( QString::fromStdString( key ),
|
||||
CalamaresPython::variantFromPyObject( value ) );
|
||||
m_gs->insert( QString::fromStdString( key ), CalamaresPython::variantFromPyObject( value ) );
|
||||
}
|
||||
|
||||
bp::list
|
||||
@ -207,7 +216,9 @@ GlobalStoragePythonWrapper::keys() const
|
||||
bp::list pyList;
|
||||
const auto keys = m_gs->keys();
|
||||
for ( const QString& key : keys )
|
||||
{
|
||||
pyList.append( key.toStdString() );
|
||||
}
|
||||
return pyList;
|
||||
}
|
||||
|
||||
@ -225,6 +236,6 @@ GlobalStoragePythonWrapper::value( const std::string& key ) const
|
||||
return CalamaresPython::variantToPyObject( m_gs->value( QString::fromStdString( key ) ) );
|
||||
}
|
||||
|
||||
} // namespace CalamaresPython
|
||||
} // namespace CalamaresPython
|
||||
|
||||
#endif // WITH_PYTHON
|
||||
#endif // WITH_PYTHON
|
||||
|
@ -34,8 +34,8 @@ namespace api
|
||||
class object;
|
||||
}
|
||||
class list;
|
||||
}
|
||||
}
|
||||
} // namespace python
|
||||
} // namespace boost
|
||||
#endif
|
||||
|
||||
namespace Calamares
|
||||
@ -96,7 +96,7 @@ private:
|
||||
friend DebugWindow;
|
||||
};
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
namespace CalamaresPython
|
||||
@ -124,7 +124,7 @@ private:
|
||||
static Calamares::GlobalStorage* s_gs_instance; // See globalStorageInstance()
|
||||
};
|
||||
|
||||
} // namespace CalamaresPython
|
||||
} // namespace CalamaresPython
|
||||
#endif
|
||||
|
||||
#endif // CALAMARES_GLOBALSTORAGE_H
|
||||
#endif // CALAMARES_GLOBALSTORAGE_H
|
||||
|
@ -84,7 +84,8 @@ JobResult::JobResult( const QString& message, const QString& details, int number
|
||||
: m_message( message )
|
||||
, m_details( details )
|
||||
, m_number( number )
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Job::Job( QObject* parent )
|
||||
@ -93,8 +94,7 @@ Job::Job( QObject* parent )
|
||||
}
|
||||
|
||||
|
||||
Job::~Job()
|
||||
{}
|
||||
Job::~Job() {}
|
||||
|
||||
|
||||
qreal
|
||||
@ -118,4 +118,4 @@ Job::prettyStatusMessage() const
|
||||
}
|
||||
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
@ -25,7 +25,8 @@
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
|
||||
namespace Calamares {
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
class DLLEXPORT JobResult
|
||||
{
|
||||
@ -43,7 +44,7 @@ public:
|
||||
GenericError = -1,
|
||||
PythonUncaughtException = 1,
|
||||
InvalidConfiguration = 2
|
||||
} ;
|
||||
};
|
||||
|
||||
JobResult( const JobResult& rhs ) = delete;
|
||||
JobResult( JobResult&& rhs );
|
||||
@ -102,6 +103,6 @@ private:
|
||||
using job_ptr = QSharedPointer< Job >;
|
||||
using JobList = QList< job_ptr >;
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
||||
#endif // CALAMARES_JOB_H
|
||||
#endif // CALAMARES_JOB_H
|
||||
|
@ -36,7 +36,8 @@ GoodJob::exec()
|
||||
JobResult
|
||||
FailJob::exec()
|
||||
{
|
||||
return JobResult::error( tr( "Job failed (%1)" ).arg( m_name ), tr( "Programmed job failure was explicitly requested." ) );
|
||||
return JobResult::error( tr( "Job failed (%1)" ).arg( m_name ),
|
||||
tr( "Programmed job failure was explicitly requested." ) );
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Calamares
|
||||
|
@ -21,7 +21,8 @@
|
||||
|
||||
#include "Job.h"
|
||||
|
||||
namespace Calamares {
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
/** @brief A Job with a name
|
||||
*
|
||||
@ -39,9 +40,10 @@ public:
|
||||
}
|
||||
|
||||
virtual QString prettyName() const override;
|
||||
|
||||
protected:
|
||||
const QString m_name;
|
||||
} ;
|
||||
};
|
||||
|
||||
/// @brief Job does nothing, always succeeds
|
||||
class DLLEXPORT GoodJob : public NamedJob
|
||||
@ -53,7 +55,7 @@ public:
|
||||
}
|
||||
|
||||
virtual JobResult exec() override;
|
||||
} ;
|
||||
};
|
||||
|
||||
|
||||
/// @brief Job does nothing, always fails
|
||||
@ -66,8 +68,8 @@ public:
|
||||
}
|
||||
|
||||
virtual JobResult exec() override;
|
||||
} ;
|
||||
};
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
||||
#endif // CALAMARES_JOB_EXAMPLE_H
|
||||
#endif // CALAMARES_JOB_EXAMPLE_H
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
#include "JobQueue.h"
|
||||
|
||||
#include "Job.h"
|
||||
#include "GlobalStorage.h"
|
||||
#include "Job.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include "CalamaresConfig.h"
|
||||
@ -50,14 +50,14 @@ public:
|
||||
m_jobs = jobs;
|
||||
|
||||
qreal totalJobsWeight = 0.0;
|
||||
for( auto job : m_jobs )
|
||||
for ( auto job : m_jobs )
|
||||
{
|
||||
totalJobsWeight += job->getJobWeight();
|
||||
}
|
||||
for( auto job : m_jobs )
|
||||
for ( auto job : m_jobs )
|
||||
{
|
||||
qreal jobWeight = qreal( job->getJobWeight() / totalJobsWeight );
|
||||
m_jobWeights.append( jobWeight ) ;
|
||||
m_jobWeights.append( jobWeight );
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public:
|
||||
QString details;
|
||||
|
||||
m_jobIndex = 0;
|
||||
for( auto job : m_jobs )
|
||||
for ( auto job : m_jobs )
|
||||
{
|
||||
if ( anyFailed && !job->isEmergency() )
|
||||
{
|
||||
@ -87,12 +87,18 @@ public:
|
||||
details = result.details();
|
||||
}
|
||||
if ( !anyFailed )
|
||||
{
|
||||
++m_jobIndex;
|
||||
}
|
||||
}
|
||||
if ( anyFailed )
|
||||
{
|
||||
emitFailed( message, details );
|
||||
}
|
||||
else
|
||||
{
|
||||
emitProgress();
|
||||
}
|
||||
emitFinished();
|
||||
}
|
||||
|
||||
@ -109,49 +115,39 @@ private:
|
||||
jobPercent = qBound( qreal( 0 ), jobPercent, qreal( 1 ) );
|
||||
|
||||
int jobCount = m_jobs.size();
|
||||
QString message = m_jobIndex < jobCount
|
||||
? m_jobs.at( m_jobIndex )->prettyStatusMessage()
|
||||
: tr( "Done" );
|
||||
QString message = m_jobIndex < jobCount ? m_jobs.at( m_jobIndex )->prettyStatusMessage() : tr( "Done" );
|
||||
|
||||
qreal cumulativeProgress = 0.0;
|
||||
for( auto jobWeight : m_jobWeights.mid( 0, m_jobIndex ) )
|
||||
for ( auto jobWeight : m_jobWeights.mid( 0, m_jobIndex ) )
|
||||
{
|
||||
cumulativeProgress += jobWeight;
|
||||
}
|
||||
qreal percent = m_jobIndex < jobCount
|
||||
? cumulativeProgress + ( ( m_jobWeights.at( m_jobIndex ) ) * jobPercent )
|
||||
: 1.0;
|
||||
qreal percent
|
||||
= m_jobIndex < jobCount ? cumulativeProgress + ( ( m_jobWeights.at( m_jobIndex ) ) * jobPercent ) : 1.0;
|
||||
|
||||
if (m_jobIndex < jobCount)
|
||||
if ( m_jobIndex < jobCount )
|
||||
{
|
||||
cDebug(Logger::LOGVERBOSE) << "[JOBQUEUE]: Progress for Job[" << m_jobIndex << "]: " << ( jobPercent * 100 ) << "% completed";
|
||||
cDebug(Logger::LOGVERBOSE) << "[JOBQUEUE]: Progress Overall: " << ( cumulativeProgress * 100 ) << "% (accumulated) + "
|
||||
<< ( ( ( m_jobWeights.at( m_jobIndex ) ) * jobPercent ) * 100 ) << "% (this job) = "
|
||||
<< ( percent * 100 ) << "% (total)";
|
||||
cDebug( Logger::LOGVERBOSE ) << "[JOBQUEUE]: Progress for Job[" << m_jobIndex
|
||||
<< "]: " << ( jobPercent * 100 ) << "% completed";
|
||||
cDebug( Logger::LOGVERBOSE ) << "[JOBQUEUE]: Progress Overall: " << ( cumulativeProgress * 100 )
|
||||
<< "% (accumulated) + "
|
||||
<< ( ( ( m_jobWeights.at( m_jobIndex ) ) * jobPercent ) * 100 )
|
||||
<< "% (this job) = " << ( percent * 100 ) << "% (total)";
|
||||
}
|
||||
QMetaObject::invokeMethod( m_queue, "progress", Qt::QueuedConnection,
|
||||
Q_ARG( qreal, percent ),
|
||||
Q_ARG( QString, message )
|
||||
);
|
||||
QMetaObject::invokeMethod(
|
||||
m_queue, "progress", Qt::QueuedConnection, Q_ARG( qreal, percent ), Q_ARG( QString, message ) );
|
||||
}
|
||||
|
||||
void emitFailed( const QString& message, const QString& details )
|
||||
{
|
||||
QMetaObject::invokeMethod( m_queue, "failed", Qt::QueuedConnection,
|
||||
Q_ARG( QString, message ),
|
||||
Q_ARG( QString, details )
|
||||
);
|
||||
QMetaObject::invokeMethod(
|
||||
m_queue, "failed", Qt::QueuedConnection, Q_ARG( QString, message ), Q_ARG( QString, details ) );
|
||||
}
|
||||
|
||||
void emitFinished()
|
||||
{
|
||||
QMetaObject::invokeMethod( m_queue, "finished", Qt::QueuedConnection );
|
||||
}
|
||||
void emitFinished() { QMetaObject::invokeMethod( m_queue, "finished", Qt::QueuedConnection ); }
|
||||
};
|
||||
|
||||
JobThread::~JobThread()
|
||||
{
|
||||
}
|
||||
JobThread::~JobThread() {}
|
||||
|
||||
|
||||
JobQueue* JobQueue::s_instance = nullptr;
|
||||
@ -186,8 +182,10 @@ JobQueue::~JobQueue()
|
||||
if ( m_thread->isRunning() )
|
||||
{
|
||||
m_thread->terminate();
|
||||
if ( !m_thread->wait(300) )
|
||||
if ( !m_thread->wait( 300 ) )
|
||||
{
|
||||
cError() << "Could not terminate job thread (expect a crash now).";
|
||||
}
|
||||
delete m_thread;
|
||||
}
|
||||
|
||||
@ -222,4 +220,4 @@ JobQueue::enqueue( const JobList& jobs )
|
||||
emit queueChanged( m_jobs );
|
||||
}
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
@ -59,6 +59,6 @@ private:
|
||||
GlobalStorage* m_storage;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Calamares
|
||||
|
||||
#endif // CALAMARES_JOBQUEUE_H
|
||||
#endif // CALAMARES_JOBQUEUE_H
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef PLUGINDLLEXPORT
|
||||
# if defined (PLUGINDLLEXPORT_PRO)
|
||||
# define PLUGINDLLEXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define PLUGINDLLEXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#if defined( PLUGINDLLEXPORT_PRO )
|
||||
#define PLUGINDLLEXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define PLUGINDLLEXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -25,7 +25,8 @@
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
|
||||
namespace Calamares {
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
|
||||
ProcessJob::ProcessJob( const QString& command,
|
||||
@ -38,27 +39,24 @@ ProcessJob::ProcessJob( const QString& command,
|
||||
, m_workingPath( workingPath )
|
||||
, m_runInChroot( runInChroot )
|
||||
, m_timeoutSec( secondsTimeout )
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ProcessJob::~ProcessJob()
|
||||
{}
|
||||
ProcessJob::~ProcessJob() {}
|
||||
|
||||
|
||||
QString
|
||||
ProcessJob::prettyName() const
|
||||
{
|
||||
return ( m_runInChroot ? tr( "Run command '%1' in target system." ) : tr( " Run command '%1'." ) )
|
||||
.arg( m_command );
|
||||
return ( m_runInChroot ? tr( "Run command '%1' in target system." ) : tr( " Run command '%1'." ) ).arg( m_command );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
ProcessJob::prettyStatusMessage() const
|
||||
{
|
||||
return tr( "Running command %1 %2" )
|
||||
.arg( m_command )
|
||||
.arg( m_runInChroot ? "in chroot." : " ." );
|
||||
return tr( "Running command %1 %2" ).arg( m_command ).arg( m_runInChroot ? "in chroot." : " ." );
|
||||
}
|
||||
|
||||
|
||||
@ -68,20 +66,16 @@ ProcessJob::exec()
|
||||
using CalamaresUtils::System;
|
||||
|
||||
if ( m_runInChroot )
|
||||
return CalamaresUtils::System::instance()->
|
||||
targetEnvCommand( { m_command },
|
||||
m_workingPath,
|
||||
QString(),
|
||||
m_timeoutSec )
|
||||
.explainProcess( m_command, m_timeoutSec );
|
||||
return CalamaresUtils::System::instance()
|
||||
->targetEnvCommand( { m_command }, m_workingPath, QString(), m_timeoutSec )
|
||||
.explainProcess( m_command, m_timeoutSec );
|
||||
else
|
||||
return
|
||||
System::runCommand( System::RunLocation::RunInHost,
|
||||
{ "/bin/sh", "-c", m_command },
|
||||
m_workingPath,
|
||||
QString(),
|
||||
m_timeoutSec )
|
||||
return System::runCommand( System::RunLocation::RunInHost,
|
||||
{ "/bin/sh", "-c", m_command },
|
||||
m_workingPath,
|
||||
QString(),
|
||||
m_timeoutSec )
|
||||
.explainProcess( m_command, m_timeoutSec );
|
||||
}
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
@ -24,7 +24,8 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace Calamares {
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
class ProcessJob : public Job
|
||||
{
|
||||
@ -33,7 +34,7 @@ public:
|
||||
explicit ProcessJob( const QString& command,
|
||||
const QString& workingPath,
|
||||
bool runInChroot = false,
|
||||
std::chrono::seconds secondsTimeout = std::chrono::seconds(30),
|
||||
std::chrono::seconds secondsTimeout = std::chrono::seconds( 30 ),
|
||||
QObject* parent = nullptr );
|
||||
virtual ~ProcessJob() override;
|
||||
|
||||
@ -48,6 +49,6 @@ private:
|
||||
std::chrono::seconds m_timeoutSec;
|
||||
};
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
||||
#endif // CALAMARES_PROCESSJOB_H
|
||||
#endif // CALAMARES_PROCESSJOB_H
|
||||
|
@ -72,25 +72,39 @@ variantFromPyObject( const boost::python::object& pyObject )
|
||||
{
|
||||
std::string pyType = bp::extract< std::string >( pyObject.attr( "__class__" ).attr( "__name__" ) );
|
||||
if ( pyType == "dict" )
|
||||
{
|
||||
return variantMapFromPyDict( bp::extract< bp::dict >( pyObject ) );
|
||||
}
|
||||
|
||||
else if ( pyType == "list" )
|
||||
{
|
||||
return variantListFromPyList( bp::extract< bp::list >( pyObject ) );
|
||||
}
|
||||
|
||||
else if ( pyType == "int" )
|
||||
{
|
||||
return QVariant( bp::extract< int >( pyObject ) );
|
||||
}
|
||||
|
||||
else if ( pyType == "float" )
|
||||
{
|
||||
return QVariant( bp::extract< double >( pyObject ) );
|
||||
}
|
||||
|
||||
else if ( pyType == "str" )
|
||||
{
|
||||
return QVariant( QString::fromStdString( bp::extract< std::string >( pyObject ) ) );
|
||||
}
|
||||
|
||||
else if ( pyType == "bool" )
|
||||
{
|
||||
return QVariant( bp::extract< bool >( pyObject ) );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +113,9 @@ variantListToPyList( const QVariantList& variantList )
|
||||
{
|
||||
bp::list pyList;
|
||||
for ( const QVariant& variant : variantList )
|
||||
{
|
||||
pyList.append( variantToPyObject( variant ) );
|
||||
}
|
||||
return pyList;
|
||||
}
|
||||
|
||||
@ -109,7 +125,9 @@ variantListFromPyList( const boost::python::list& pyList )
|
||||
{
|
||||
QVariantList list;
|
||||
for ( int i = 0; i < bp::len( pyList ); ++i )
|
||||
{
|
||||
list.append( variantFromPyObject( pyList[ i ] ) );
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -119,7 +137,9 @@ variantMapToPyDict( const QVariantMap& variantMap )
|
||||
{
|
||||
bp::dict pyDict;
|
||||
for ( auto it = variantMap.constBegin(); it != variantMap.constEnd(); ++it )
|
||||
{
|
||||
pyDict[ it.key().toStdString() ] = variantToPyObject( it.value() );
|
||||
}
|
||||
return pyDict;
|
||||
}
|
||||
|
||||
@ -152,7 +172,9 @@ variantHashToPyDict( const QVariantHash& variantHash )
|
||||
{
|
||||
bp::dict pyDict;
|
||||
for ( auto it = variantHash.constBegin(); it != variantHash.constEnd(); ++it )
|
||||
{
|
||||
pyDict[ it.key().toStdString() ] = variantToPyObject( it.value() );
|
||||
}
|
||||
return pyDict;
|
||||
}
|
||||
|
||||
@ -181,17 +203,21 @@ variantHashFromPyDict( const boost::python::dict& pyDict )
|
||||
}
|
||||
|
||||
|
||||
|
||||
Helper* Helper::s_instance = nullptr;
|
||||
|
||||
static inline void add_if_lib_exists( const QDir& dir, const char* name, QStringList& list )
|
||||
static inline void
|
||||
add_if_lib_exists( const QDir& dir, const char* name, QStringList& list )
|
||||
{
|
||||
if ( ! ( dir.exists() && dir.isReadable() ) )
|
||||
if ( !( dir.exists() && dir.isReadable() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QFileInfo fi( dir.absoluteFilePath( name ) );
|
||||
if ( fi.exists() && fi.isReadable() )
|
||||
{
|
||||
list.append( fi.dir().absolutePath() );
|
||||
}
|
||||
}
|
||||
|
||||
Helper::Helper( QObject* parent )
|
||||
@ -201,7 +227,9 @@ Helper::Helper( QObject* parent )
|
||||
if ( !s_instance )
|
||||
{
|
||||
if ( !Py_IsInitialized() )
|
||||
{
|
||||
Py_Initialize();
|
||||
}
|
||||
|
||||
m_mainModule = bp::import( "__main__" );
|
||||
m_mainNamespace = m_mainModule.attr( "__dict__" );
|
||||
@ -209,8 +237,7 @@ Helper::Helper( QObject* parent )
|
||||
// If we're running from the build dir
|
||||
add_if_lib_exists( QDir::current(), "libcalamares.so", m_pythonPaths );
|
||||
|
||||
QDir calaPythonPath( CalamaresUtils::systemLibDir().absolutePath() +
|
||||
QDir::separator() + "calamares" );
|
||||
QDir calaPythonPath( CalamaresUtils::systemLibDir().absolutePath() + QDir::separator() + "calamares" );
|
||||
add_if_lib_exists( calaPythonPath, "libcalamares.so", m_pythonPaths );
|
||||
|
||||
bp::object sys = bp::import( "sys" );
|
||||
@ -251,7 +278,7 @@ Helper::createCleanNamespace()
|
||||
QString
|
||||
Helper::handleLastError()
|
||||
{
|
||||
PyObject* type = nullptr, *val = nullptr, *traceback_p = nullptr;
|
||||
PyObject *type = nullptr, *val = nullptr, *traceback_p = nullptr;
|
||||
PyErr_Fetch( &type, &val, &traceback_p );
|
||||
|
||||
Logger::CDebug debug;
|
||||
@ -264,10 +291,14 @@ Helper::handleLastError()
|
||||
bp::str pystr( h_type );
|
||||
bp::extract< std::string > extracted( pystr );
|
||||
if ( extracted.check() )
|
||||
{
|
||||
typeMsg = QString::fromStdString( extracted() ).trimmed();
|
||||
}
|
||||
|
||||
if ( typeMsg.isEmpty() )
|
||||
{
|
||||
typeMsg = tr( "Unknown exception type" );
|
||||
}
|
||||
debug << typeMsg << '\n';
|
||||
}
|
||||
|
||||
@ -278,10 +309,14 @@ Helper::handleLastError()
|
||||
bp::str pystr( h_val );
|
||||
bp::extract< std::string > extracted( pystr );
|
||||
if ( extracted.check() )
|
||||
{
|
||||
valMsg = QString::fromStdString( extracted() ).trimmed();
|
||||
}
|
||||
|
||||
if ( valMsg.isEmpty() )
|
||||
{
|
||||
valMsg = tr( "unparseable Python error" );
|
||||
}
|
||||
|
||||
// Special-case: CalledProcessError has an attribute "output" with the command output,
|
||||
// add that to the printed message.
|
||||
@ -318,22 +353,32 @@ Helper::handleLastError()
|
||||
bp::object pystr( bp::str( "\n" ).join( tb_list ) );
|
||||
bp::extract< std::string > extracted( pystr );
|
||||
if ( extracted.check() )
|
||||
{
|
||||
tbMsg = QString::fromStdString( extracted() ).trimmed();
|
||||
}
|
||||
|
||||
if ( tbMsg.isEmpty() )
|
||||
{
|
||||
tbMsg = tr( "unparseable Python traceback" );
|
||||
}
|
||||
debug << tbMsg << '\n';
|
||||
}
|
||||
|
||||
if ( typeMsg.isEmpty() && valMsg.isEmpty() && tbMsg.isEmpty() )
|
||||
{
|
||||
return tr( "Unfetchable Python error." );
|
||||
}
|
||||
|
||||
|
||||
QStringList msgList;
|
||||
if ( !typeMsg.isEmpty() )
|
||||
{
|
||||
msgList.append( QString( "<strong>%1</strong>" ).arg( typeMsg.toHtmlEscaped() ) );
|
||||
}
|
||||
if ( !valMsg.isEmpty() )
|
||||
{
|
||||
msgList.append( valMsg.toHtmlEscaped() );
|
||||
}
|
||||
|
||||
if ( !tbMsg.isEmpty() )
|
||||
{
|
||||
@ -346,4 +391,4 @@ Helper::handleLastError()
|
||||
}
|
||||
|
||||
|
||||
} // namespace CalamaresPython
|
||||
} // namespace CalamaresPython
|
||||
|
@ -32,17 +32,17 @@
|
||||
namespace CalamaresPython
|
||||
{
|
||||
|
||||
boost::python::object variantToPyObject( const QVariant& variant );
|
||||
QVariant variantFromPyObject( const boost::python::object& pyObject );
|
||||
boost::python::object variantToPyObject( const QVariant& variant );
|
||||
QVariant variantFromPyObject( const boost::python::object& pyObject );
|
||||
|
||||
boost::python::list variantListToPyList( const QVariantList& variantList );
|
||||
QVariantList variantListFromPyList( const boost::python::list& pyList );
|
||||
boost::python::list variantListToPyList( const QVariantList& variantList );
|
||||
QVariantList variantListFromPyList( const boost::python::list& pyList );
|
||||
|
||||
boost::python::dict variantMapToPyDict( const QVariantMap& variantMap );
|
||||
QVariantMap variantMapFromPyDict( const boost::python::dict& pyDict );
|
||||
boost::python::dict variantMapToPyDict( const QVariantMap& variantMap );
|
||||
QVariantMap variantMapFromPyDict( const boost::python::dict& pyDict );
|
||||
|
||||
boost::python::dict variantHashToPyDict( const QVariantHash& variantHash );
|
||||
QVariantHash variantHashFromPyDict( const boost::python::dict& pyDict );
|
||||
boost::python::dict variantHashToPyDict( const QVariantHash& variantHash );
|
||||
QVariantHash variantHashFromPyDict( const boost::python::dict& pyDict );
|
||||
|
||||
|
||||
class Helper : public QObject
|
||||
@ -66,6 +66,6 @@ private:
|
||||
QStringList m_pythonPaths;
|
||||
};
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace CalamaresPython
|
||||
|
||||
#endif // CALAMARES_PYTHONJOBHELPER_H
|
||||
#endif // CALAMARES_PYTHONJOBHELPER_H
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
#include "PythonJob.h"
|
||||
|
||||
#include "PythonHelper.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "PythonHelper.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
@ -35,27 +35,19 @@
|
||||
|
||||
namespace bp = boost::python;
|
||||
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( mount_overloads,
|
||||
CalamaresPython::mount,
|
||||
2, 4 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( target_env_call_str_overloads,
|
||||
CalamaresPython::target_env_call,
|
||||
1, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( target_env_call_list_overloads,
|
||||
CalamaresPython::target_env_call,
|
||||
1, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_call_str_overloads,
|
||||
CalamaresPython::check_target_env_call,
|
||||
1, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_call_list_overloads,
|
||||
CalamaresPython::check_target_env_call,
|
||||
1, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( mount_overloads, CalamaresPython::mount, 2, 4 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( target_env_call_str_overloads, CalamaresPython::target_env_call, 1, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( target_env_call_list_overloads, CalamaresPython::target_env_call, 1, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_call_str_overloads, CalamaresPython::check_target_env_call, 1, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_call_list_overloads, CalamaresPython::check_target_env_call, 1, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_output_str_overloads,
|
||||
CalamaresPython::check_target_env_output,
|
||||
1, 3 );
|
||||
1,
|
||||
3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_output_list_overloads,
|
||||
CalamaresPython::check_target_env_output,
|
||||
1, 3 );
|
||||
1,
|
||||
3 );
|
||||
BOOST_PYTHON_MODULE( libcalamares )
|
||||
{
|
||||
bp::object package = bp::scope();
|
||||
@ -68,25 +60,24 @@ BOOST_PYTHON_MODULE( libcalamares )
|
||||
bp::scope().attr( "VERSION_SHORT" ) = CALAMARES_VERSION_SHORT;
|
||||
|
||||
bp::class_< CalamaresPython::PythonJobInterface >( "Job", bp::init< Calamares::PythonJob* >() )
|
||||
.def_readonly( "module_name", &CalamaresPython::PythonJobInterface::moduleName )
|
||||
.def_readonly( "pretty_name", &CalamaresPython::PythonJobInterface::prettyName )
|
||||
.def_readonly( "working_path", &CalamaresPython::PythonJobInterface::workingPath )
|
||||
.def_readonly( "module_name", &CalamaresPython::PythonJobInterface::moduleName )
|
||||
.def_readonly( "pretty_name", &CalamaresPython::PythonJobInterface::prettyName )
|
||||
.def_readonly( "working_path", &CalamaresPython::PythonJobInterface::workingPath )
|
||||
.def_readonly( "configuration", &CalamaresPython::PythonJobInterface::configuration )
|
||||
.def(
|
||||
"setprogress",
|
||||
&CalamaresPython::PythonJobInterface::setprogress,
|
||||
bp::args( "progress" ),
|
||||
"Reports the progress status of this job to Calamares, "
|
||||
"as a real number between 0 and 1."
|
||||
);
|
||||
.def( "setprogress",
|
||||
&CalamaresPython::PythonJobInterface::setprogress,
|
||||
bp::args( "progress" ),
|
||||
"Reports the progress status of this job to Calamares, "
|
||||
"as a real number between 0 and 1." );
|
||||
|
||||
bp::class_< CalamaresPython::GlobalStoragePythonWrapper >( "GlobalStorage", bp::init< Calamares::GlobalStorage* >() )
|
||||
.def( "contains", &CalamaresPython::GlobalStoragePythonWrapper::contains )
|
||||
.def( "count", &CalamaresPython::GlobalStoragePythonWrapper::count )
|
||||
.def( "insert", &CalamaresPython::GlobalStoragePythonWrapper::insert )
|
||||
.def( "keys", &CalamaresPython::GlobalStoragePythonWrapper::keys )
|
||||
.def( "remove", &CalamaresPython::GlobalStoragePythonWrapper::remove )
|
||||
.def( "value", &CalamaresPython::GlobalStoragePythonWrapper::value );
|
||||
bp::class_< CalamaresPython::GlobalStoragePythonWrapper >( "GlobalStorage",
|
||||
bp::init< Calamares::GlobalStorage* >() )
|
||||
.def( "contains", &CalamaresPython::GlobalStoragePythonWrapper::contains )
|
||||
.def( "count", &CalamaresPython::GlobalStoragePythonWrapper::count )
|
||||
.def( "insert", &CalamaresPython::GlobalStoragePythonWrapper::insert )
|
||||
.def( "keys", &CalamaresPython::GlobalStoragePythonWrapper::keys )
|
||||
.def( "remove", &CalamaresPython::GlobalStoragePythonWrapper::remove )
|
||||
.def( "value", &CalamaresPython::GlobalStoragePythonWrapper::value );
|
||||
|
||||
// libcalamares.utils submodule starts here
|
||||
bp::object utilsModule( bp::handle<>( bp::borrowed( PyImport_AddModule( "libcalamares.utils" ) ) ) );
|
||||
@ -95,151 +86,88 @@ BOOST_PYTHON_MODULE( libcalamares )
|
||||
Q_UNUSED( utilsScope )
|
||||
|
||||
bp::def(
|
||||
"debug",
|
||||
&CalamaresPython::debug,
|
||||
bp::args( "s" ),
|
||||
"Writes the given string to the Calamares debug stream."
|
||||
);
|
||||
bp::def(
|
||||
"warning",
|
||||
&CalamaresPython::warning,
|
||||
bp::args( "s" ),
|
||||
"Writes the given string to the Calamares warning stream."
|
||||
);
|
||||
"debug", &CalamaresPython::debug, bp::args( "s" ), "Writes the given string to the Calamares debug stream." );
|
||||
bp::def( "warning",
|
||||
&CalamaresPython::warning,
|
||||
bp::args( "s" ),
|
||||
"Writes the given string to the Calamares warning stream." );
|
||||
|
||||
bp::def(
|
||||
"mount",
|
||||
&CalamaresPython::mount,
|
||||
mount_overloads(
|
||||
bp::args( "device_path",
|
||||
"mount_point",
|
||||
"filesystem_name",
|
||||
"options" ),
|
||||
"Runs the mount utility with the specified parameters.\n"
|
||||
"Returns the program's exit code, or:\n"
|
||||
"-1 = QProcess crash\n"
|
||||
"-2 = QProcess cannot start\n"
|
||||
"-3 = bad arguments"
|
||||
)
|
||||
);
|
||||
bp::def( "mount",
|
||||
&CalamaresPython::mount,
|
||||
mount_overloads( bp::args( "device_path", "mount_point", "filesystem_name", "options" ),
|
||||
"Runs the mount utility with the specified parameters.\n"
|
||||
"Returns the program's exit code, or:\n"
|
||||
"-1 = QProcess crash\n"
|
||||
"-2 = QProcess cannot start\n"
|
||||
"-3 = bad arguments" ) );
|
||||
bp::def(
|
||||
"target_env_call",
|
||||
static_cast< int (*)( const std::string&,
|
||||
const std::string&,
|
||||
int ) >( &CalamaresPython::target_env_call ),
|
||||
target_env_call_str_overloads(
|
||||
bp::args( "command",
|
||||
"stdin",
|
||||
"timeout" ),
|
||||
"Runs the specified command in the chroot of the target system.\n"
|
||||
"Returns the program's exit code, or:\n"
|
||||
"-1 = QProcess crash\n"
|
||||
"-2 = QProcess cannot start\n"
|
||||
"-3 = bad arguments\n"
|
||||
"-4 = QProcess timeout"
|
||||
)
|
||||
);
|
||||
bp::def(
|
||||
"target_env_call",
|
||||
static_cast< int (*)( const bp::list&,
|
||||
const std::string&,
|
||||
int ) >( &CalamaresPython::target_env_call ),
|
||||
target_env_call_list_overloads(
|
||||
bp::args( "args",
|
||||
"stdin",
|
||||
"timeout" ),
|
||||
"Runs the specified command in the chroot of the target system.\n"
|
||||
"Returns the program's exit code, or:\n"
|
||||
"-1 = QProcess crash\n"
|
||||
"-2 = QProcess cannot start\n"
|
||||
"-3 = bad arguments\n"
|
||||
"-4 = QProcess timeout"
|
||||
)
|
||||
);
|
||||
static_cast< int ( * )( const std::string&, const std::string&, int ) >( &CalamaresPython::target_env_call ),
|
||||
target_env_call_str_overloads( bp::args( "command", "stdin", "timeout" ),
|
||||
"Runs the specified command in the chroot of the target system.\n"
|
||||
"Returns the program's exit code, or:\n"
|
||||
"-1 = QProcess crash\n"
|
||||
"-2 = QProcess cannot start\n"
|
||||
"-3 = bad arguments\n"
|
||||
"-4 = QProcess timeout" ) );
|
||||
bp::def( "target_env_call",
|
||||
static_cast< int ( * )( const bp::list&, const std::string&, int ) >( &CalamaresPython::target_env_call ),
|
||||
target_env_call_list_overloads( bp::args( "args", "stdin", "timeout" ),
|
||||
"Runs the specified command in the chroot of the target system.\n"
|
||||
"Returns the program's exit code, or:\n"
|
||||
"-1 = QProcess crash\n"
|
||||
"-2 = QProcess cannot start\n"
|
||||
"-3 = bad arguments\n"
|
||||
"-4 = QProcess timeout" ) );
|
||||
|
||||
bp::def( "check_target_env_call",
|
||||
static_cast< int ( * )( const std::string&, const std::string&, int ) >(
|
||||
&CalamaresPython::check_target_env_call ),
|
||||
check_target_env_call_str_overloads( bp::args( "command", "stdin", "timeout" ),
|
||||
"Runs the specified command in the chroot of the target system.\n"
|
||||
"Returns 0, which is program's exit code if the program exited "
|
||||
"successfully, or raises a subprocess.CalledProcessError." ) );
|
||||
bp::def(
|
||||
"check_target_env_call",
|
||||
static_cast< int (*)( const std::string&,
|
||||
const std::string&,
|
||||
int ) >( &CalamaresPython::check_target_env_call ),
|
||||
check_target_env_call_str_overloads(
|
||||
bp::args( "command",
|
||||
"stdin",
|
||||
"timeout" ),
|
||||
"Runs the specified command in the chroot of the target system.\n"
|
||||
"Returns 0, which is program's exit code if the program exited "
|
||||
"successfully, or raises a subprocess.CalledProcessError."
|
||||
)
|
||||
);
|
||||
bp::def(
|
||||
"check_target_env_call",
|
||||
static_cast< int (*)( const bp::list&,
|
||||
const std::string&,
|
||||
int ) >( &CalamaresPython::check_target_env_call ),
|
||||
check_target_env_call_list_overloads(
|
||||
bp::args( "args",
|
||||
"stdin",
|
||||
"timeout" ),
|
||||
"Runs the specified command in the chroot of the target system.\n"
|
||||
"Returns 0, which is program's exit code if the program exited "
|
||||
"successfully, or raises a subprocess.CalledProcessError."
|
||||
)
|
||||
);
|
||||
static_cast< int ( * )( const bp::list&, const std::string&, int ) >( &CalamaresPython::check_target_env_call ),
|
||||
check_target_env_call_list_overloads( bp::args( "args", "stdin", "timeout" ),
|
||||
"Runs the specified command in the chroot of the target system.\n"
|
||||
"Returns 0, which is program's exit code if the program exited "
|
||||
"successfully, or raises a subprocess.CalledProcessError." ) );
|
||||
|
||||
bp::def(
|
||||
"check_target_env_output",
|
||||
static_cast< std::string (*)( const std::string&,
|
||||
const std::string&,
|
||||
int ) >( &CalamaresPython::check_target_env_output ),
|
||||
check_target_env_output_str_overloads(
|
||||
bp::args( "command",
|
||||
"stdin",
|
||||
"timeout" ),
|
||||
"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(
|
||||
"check_target_env_output",
|
||||
static_cast< std::string (*)( const bp::list&,
|
||||
const std::string&,
|
||||
int ) >( &CalamaresPython::check_target_env_output ),
|
||||
check_target_env_output_list_overloads(
|
||||
bp::args( "args",
|
||||
"stdin",
|
||||
"timeout" ),
|
||||
"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(
|
||||
"obscure",
|
||||
&CalamaresPython::obscure,
|
||||
bp::args( "s" ),
|
||||
"Simple string obfuscation function based on KStringHandler::obscure.\n"
|
||||
"Returns a string, generated using a simple symmetric encryption.\n"
|
||||
"Applying the function to a string obscured by this function will result "
|
||||
"in the original string."
|
||||
);
|
||||
bp::def( "check_target_env_output",
|
||||
static_cast< std::string ( * )( const std::string&, const std::string&, int ) >(
|
||||
&CalamaresPython::check_target_env_output ),
|
||||
check_target_env_output_str_overloads( bp::args( "command", "stdin", "timeout" ),
|
||||
"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( "check_target_env_output",
|
||||
static_cast< std::string ( * )( const bp::list&, const std::string&, int ) >(
|
||||
&CalamaresPython::check_target_env_output ),
|
||||
check_target_env_output_list_overloads( bp::args( "args", "stdin", "timeout" ),
|
||||
"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( "obscure",
|
||||
&CalamaresPython::obscure,
|
||||
bp::args( "s" ),
|
||||
"Simple string obfuscation function based on KStringHandler::obscure.\n"
|
||||
"Returns a string, generated using a simple symmetric encryption.\n"
|
||||
"Applying the function to a string obscured by this function will result "
|
||||
"in the original string." );
|
||||
|
||||
|
||||
bp::def(
|
||||
"gettext_languages",
|
||||
&CalamaresPython::gettext_languages,
|
||||
"Returns list of languages (most to least-specific) for gettext."
|
||||
);
|
||||
bp::def( "gettext_languages",
|
||||
&CalamaresPython::gettext_languages,
|
||||
"Returns list of languages (most to least-specific) for gettext." );
|
||||
|
||||
bp::def(
|
||||
"gettext_path",
|
||||
&CalamaresPython::gettext_path,
|
||||
"Returns path for gettext search."
|
||||
);
|
||||
bp::def( "gettext_path", &CalamaresPython::gettext_path, "Returns path for gettext search." );
|
||||
}
|
||||
|
||||
|
||||
namespace Calamares {
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
|
||||
PythonJob::PythonJob( const QString& scriptFile,
|
||||
@ -255,8 +183,7 @@ PythonJob::PythonJob( const QString& scriptFile,
|
||||
}
|
||||
|
||||
|
||||
PythonJob::~PythonJob()
|
||||
{}
|
||||
PythonJob::~PythonJob() {}
|
||||
|
||||
|
||||
QString
|
||||
@ -270,10 +197,11 @@ QString
|
||||
PythonJob::prettyStatusMessage() const
|
||||
{
|
||||
if ( m_description.isEmpty() )
|
||||
return tr( "Running %1 operation." )
|
||||
.arg( QDir( m_workingPath ).dirName() );
|
||||
return tr( "Running %1 operation." ).arg( QDir( m_workingPath ).dirName() );
|
||||
else
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -282,24 +210,20 @@ PythonJob::exec()
|
||||
{
|
||||
// We assume m_scriptFile to be relative to m_workingPath.
|
||||
QDir workingDir( m_workingPath );
|
||||
if ( !workingDir.exists() ||
|
||||
!workingDir.isReadable() )
|
||||
if ( !workingDir.exists() || !workingDir.isReadable() )
|
||||
{
|
||||
return JobResult::error( tr( "Bad working directory path" ),
|
||||
tr( "Working directory %1 for python job %2 is not readable." )
|
||||
.arg( m_workingPath )
|
||||
.arg( prettyName() ) );
|
||||
return JobResult::error(
|
||||
tr( "Bad working directory path" ),
|
||||
tr( "Working directory %1 for python job %2 is not readable." ).arg( m_workingPath ).arg( prettyName() ) );
|
||||
}
|
||||
|
||||
QFileInfo scriptFI( workingDir.absoluteFilePath( m_scriptFile ) );
|
||||
if ( !scriptFI.exists() ||
|
||||
!scriptFI.isFile() ||
|
||||
!scriptFI.isReadable() )
|
||||
if ( !scriptFI.exists() || !scriptFI.isFile() || !scriptFI.isReadable() )
|
||||
{
|
||||
return JobResult::error( tr( "Bad main script file" ),
|
||||
tr( "Main script file %1 for python job %2 is not readable." )
|
||||
.arg( scriptFI.absoluteFilePath() )
|
||||
.arg( prettyName() ) );
|
||||
.arg( scriptFI.absoluteFilePath() )
|
||||
.arg( prettyName() ) );
|
||||
}
|
||||
|
||||
try
|
||||
@ -310,15 +234,14 @@ PythonJob::exec()
|
||||
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
|
||||
|
||||
calamaresNamespace[ "job" ] = CalamaresPython::PythonJobInterface( this );
|
||||
calamaresNamespace[ "globalstorage" ] = CalamaresPython::GlobalStoragePythonWrapper(
|
||||
JobQueue::instance()->globalStorage() );
|
||||
calamaresNamespace[ "globalstorage" ]
|
||||
= CalamaresPython::GlobalStoragePythonWrapper( JobQueue::instance()->globalStorage() );
|
||||
|
||||
bp::object execResult = bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(),
|
||||
scriptNamespace,
|
||||
scriptNamespace );
|
||||
bp::object execResult
|
||||
= bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(), scriptNamespace, scriptNamespace );
|
||||
|
||||
bp::object entryPoint = scriptNamespace[ "run" ];
|
||||
bp::object prettyNameFunc = scriptNamespace.get("pretty_name", bp::object());
|
||||
bp::object prettyNameFunc = scriptNamespace.get( "pretty_name", bp::object() );
|
||||
|
||||
cDebug() << "Job file" << scriptFI.absoluteFilePath();
|
||||
if ( !prettyNameFunc.is_none() )
|
||||
@ -337,14 +260,16 @@ PythonJob::exec()
|
||||
|
||||
if ( m_description.isEmpty() )
|
||||
{
|
||||
bp::extract< std::string > entryPoint_doc_attr(entryPoint.attr( "__doc__" ) );
|
||||
bp::extract< std::string > entryPoint_doc_attr( entryPoint.attr( "__doc__" ) );
|
||||
|
||||
if ( entryPoint_doc_attr.check() )
|
||||
{
|
||||
m_description = QString::fromStdString( entryPoint_doc_attr() ).trimmed();
|
||||
auto i_newline = m_description.indexOf('\n');
|
||||
auto i_newline = m_description.indexOf( '\n' );
|
||||
if ( i_newline > 0 )
|
||||
{
|
||||
m_description.truncate( i_newline );
|
||||
}
|
||||
cDebug() << "Job description from __doc__" << prettyName() << "=" << m_description;
|
||||
emit progress( 0 );
|
||||
}
|
||||
@ -356,7 +281,7 @@ PythonJob::exec()
|
||||
{
|
||||
return JobResult::ok();
|
||||
}
|
||||
else // Something happened in the Python job
|
||||
else // Something happened in the Python job
|
||||
{
|
||||
bp::tuple resultTuple = bp::extract< bp::tuple >( runResult );
|
||||
QString message = QString::fromStdString( bp::extract< std::string >( resultTuple[ 0 ] ) );
|
||||
@ -374,9 +299,7 @@ PythonJob::exec()
|
||||
bp::handle_exception();
|
||||
PyErr_Clear();
|
||||
return JobResult::internalError(
|
||||
tr( "Boost.Python error in job \"%1\"." ).arg( prettyName() ),
|
||||
msg,
|
||||
JobResult::PythonUncaughtException );
|
||||
tr( "Boost.Python error in job \"%1\"." ).arg( prettyName() ), msg, JobResult::PythonUncaughtException );
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,10 +315,12 @@ CalamaresPython::Helper*
|
||||
PythonJob::helper()
|
||||
{
|
||||
auto ptr = CalamaresPython::Helper::s_instance;
|
||||
if (!ptr)
|
||||
if ( !ptr )
|
||||
{
|
||||
ptr = new CalamaresPython::Helper;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
@ -27,9 +27,10 @@ namespace CalamaresPython
|
||||
{
|
||||
class PythonJobInterface;
|
||||
class Helper;
|
||||
}
|
||||
} // namespace CalamaresPython
|
||||
|
||||
namespace Calamares {
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
class PythonJob : public Job
|
||||
{
|
||||
@ -57,6 +58,6 @@ private:
|
||||
QVariantMap m_configurationMap;
|
||||
};
|
||||
|
||||
} // namespace Calamares
|
||||
} // namespace Calamares
|
||||
|
||||
#endif // CALAMARES_PYTHONJOB_H
|
||||
#endif // CALAMARES_PYTHONJOB_H
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include "PythonJobApi.h"
|
||||
|
||||
#include "PythonHelper.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/CalamaresUtilsSystem.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/String.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
@ -40,15 +40,19 @@ static int
|
||||
_handle_check_target_env_call_error( const CalamaresUtils::ProcessResult& ec, const QString& cmd )
|
||||
{
|
||||
if ( !ec.first )
|
||||
{
|
||||
return ec.first;
|
||||
}
|
||||
|
||||
QString raise = QString( "import subprocess\n"
|
||||
"e = subprocess.CalledProcessError(%1,\"%2\")\n" )
|
||||
.arg( ec.first )
|
||||
.arg( cmd );
|
||||
.arg( ec.first )
|
||||
.arg( cmd );
|
||||
if ( !ec.second.isEmpty() )
|
||||
raise.append( QStringLiteral("e.output = \"\"\"%1\"\"\"\n").arg( ec.second ) );
|
||||
raise.append("raise e");
|
||||
{
|
||||
raise.append( QStringLiteral( "e.output = \"\"\"%1\"\"\"\n" ).arg( ec.second ) );
|
||||
}
|
||||
raise.append( "raise e" );
|
||||
bp::exec( raise.toStdString().c_str() );
|
||||
bp::throw_error_already_set();
|
||||
return ec.first;
|
||||
@ -63,11 +67,10 @@ mount( const std::string& device_path,
|
||||
const std::string& filesystem_name,
|
||||
const std::string& options )
|
||||
{
|
||||
return CalamaresUtils::System::instance()->
|
||||
mount( QString::fromStdString( device_path ),
|
||||
QString::fromStdString( mount_point ),
|
||||
QString::fromStdString( filesystem_name ),
|
||||
QString::fromStdString( options ) );
|
||||
return CalamaresUtils::System::instance()->mount( QString::fromStdString( device_path ),
|
||||
QString::fromStdString( mount_point ),
|
||||
QString::fromStdString( filesystem_name ),
|
||||
QString::fromStdString( options ) );
|
||||
}
|
||||
|
||||
|
||||
@ -77,66 +80,50 @@ _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 ] ) ) );
|
||||
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 )
|
||||
_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 ) );
|
||||
return CalamaresUtils::System::instance()->targetEnvCommand(
|
||||
args, QString(), QString::fromStdString( stdin ), std::chrono::seconds( timeout ) );
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
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 ) );
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
if ( !ec.first )
|
||||
{
|
||||
return ec.first;
|
||||
}
|
||||
|
||||
QStringList failedCmdList = _bp_list_to_qstringlist( args );
|
||||
return _handle_check_target_env_call_error( ec, failedCmdList.join( ' ' ) );
|
||||
@ -144,25 +131,19 @@ check_target_env_call( const bp::list& args,
|
||||
|
||||
|
||||
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 ) );
|
||||
return ec.second.toStdString();
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
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( ' ' ) );
|
||||
return ec.second.toStdString();
|
||||
}
|
||||
@ -194,7 +175,9 @@ void
|
||||
PythonJobInterface::setprogress( qreal progress )
|
||||
{
|
||||
if ( progress >= 0 && progress <= 1 )
|
||||
{
|
||||
m_parent->emitProgress( progress );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +199,8 @@ _gettext_languages()
|
||||
// own GlobalStoragePythonWrapper, which then holds a
|
||||
// GlobalStorage object for all of Python.
|
||||
Calamares::JobQueue* jq = Calamares::JobQueue::instance();
|
||||
Calamares::GlobalStorage* gs = jq ? jq->globalStorage() : CalamaresPython::GlobalStoragePythonWrapper::globalStorageInstance();
|
||||
Calamares::GlobalStorage* gs
|
||||
= jq ? jq->globalStorage() : CalamaresPython::GlobalStoragePythonWrapper::globalStorageInstance();
|
||||
|
||||
QVariant localeConf_ = gs->value( "localeConf" );
|
||||
if ( localeConf_.canConvert< QVariantMap >() )
|
||||
@ -246,7 +230,9 @@ gettext_languages()
|
||||
{
|
||||
bp::list pyList;
|
||||
for ( auto lang : _gettext_languages() )
|
||||
{
|
||||
pyList.append( lang.toStdString() );
|
||||
}
|
||||
return pyList;
|
||||
}
|
||||
|
||||
@ -257,7 +243,9 @@ _add_localedirs( QStringList& pathList, const QString& candidate )
|
||||
{
|
||||
pathList.prepend( candidate );
|
||||
if ( QDir( candidate ).cd( "lang" ) )
|
||||
{
|
||||
pathList.prepend( candidate + "/lang" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,16 +254,19 @@ gettext_path()
|
||||
{
|
||||
// TODO: distinguish between -d runs and normal runs
|
||||
// TODO: can we detect DESTDIR-installs?
|
||||
QStringList candidatePaths = QStandardPaths::locateAll( QStandardPaths::GenericDataLocation, "locale", QStandardPaths::LocateDirectory );
|
||||
QStringList candidatePaths
|
||||
= QStandardPaths::locateAll( QStandardPaths::GenericDataLocation, "locale", QStandardPaths::LocateDirectory );
|
||||
QString extra = QCoreApplication::applicationDirPath();
|
||||
_add_localedirs( candidatePaths, extra ); // Often /usr/local/bin
|
||||
_add_localedirs( candidatePaths, extra ); // Often /usr/local/bin
|
||||
if ( !extra.isEmpty() )
|
||||
{
|
||||
QDir d( extra );
|
||||
if ( d.cd( "../share/locale" ) ) // Often /usr/local/bin/../share/locale -> /usr/local/share/locale
|
||||
if ( d.cd( "../share/locale" ) ) // Often /usr/local/bin/../share/locale -> /usr/local/share/locale
|
||||
{
|
||||
_add_localedirs( candidatePaths, d.canonicalPath() );
|
||||
}
|
||||
}
|
||||
_add_localedirs( candidatePaths, QDir().canonicalPath() ); // .
|
||||
_add_localedirs( candidatePaths, QDir().canonicalPath() ); // .
|
||||
|
||||
cDebug() << "Determining gettext path from" << candidatePaths;
|
||||
|
||||
@ -296,4 +287,4 @@ gettext_path()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace CalamaresPython
|
||||
|
@ -35,29 +35,19 @@ int mount( const std::string& device_path,
|
||||
const std::string& filesystem_name = std::string(),
|
||||
const std::string& options = std::string() );
|
||||
|
||||
int target_env_call( const std::string& command,
|
||||
const std::string& stdin = std::string(),
|
||||
int timeout = 0 );
|
||||
int target_env_call( const std::string& command, const std::string& stdin = std::string(), int timeout = 0 );
|
||||
|
||||
int target_env_call( const boost::python::list& args,
|
||||
const std::string& stdin = std::string(),
|
||||
int timeout = 0 );
|
||||
int target_env_call( const boost::python::list& args, const std::string& stdin = std::string(), int timeout = 0 );
|
||||
|
||||
int check_target_env_call( const std::string& command,
|
||||
const std::string& stdin = std::string(),
|
||||
int timeout = 0 );
|
||||
int check_target_env_call( const std::string& command, const std::string& stdin = std::string(), int timeout = 0 );
|
||||
|
||||
int check_target_env_call( const boost::python::list& args,
|
||||
const std::string& stdin = std::string(),
|
||||
int timeout = 0 );
|
||||
int check_target_env_call( const boost::python::list& args, const std::string& stdin = std::string(), int timeout = 0 );
|
||||
|
||||
std::string check_target_env_output( const std::string& command,
|
||||
const std::string& stdin = std::string(),
|
||||
int timeout = 0 );
|
||||
std::string
|
||||
check_target_env_output( const std::string& command, const std::string& stdin = std::string(), int timeout = 0 );
|
||||
|
||||
std::string check_target_env_output( const boost::python::list& args,
|
||||
const std::string& stdin = std::string(),
|
||||
int timeout = 0 );
|
||||
std::string
|
||||
check_target_env_output( const boost::python::list& args, const std::string& stdin = std::string(), int timeout = 0 );
|
||||
|
||||
std::string obscure( const std::string& string );
|
||||
|
||||
@ -85,6 +75,6 @@ private:
|
||||
Calamares::PythonJob* m_parent;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CalamaresPython
|
||||
|
||||
#endif // PYTHONJOBAPI_H
|
||||
#endif // PYTHONJOBAPI_H
|
||||
|
@ -40,8 +40,10 @@ static QString
|
||||
requireString( const YAML::Node& config, const char* key )
|
||||
{
|
||||
auto v = config[ key ];
|
||||
if ( hasValue(v) )
|
||||
if ( hasValue( v ) )
|
||||
{
|
||||
return QString::fromStdString( v.as< std::string >() );
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << Logger::SubEntry << "Required settings.conf key" << key << "is missing.";
|
||||
@ -54,8 +56,10 @@ static bool
|
||||
requireBool( const YAML::Node& config, const char* key, bool d )
|
||||
{
|
||||
auto v = config[ key ];
|
||||
if ( hasValue(v) )
|
||||
if ( hasValue( v ) )
|
||||
{
|
||||
return v.as< bool >();
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << Logger::SubEntry << "Required settings.conf key" << key << "is missing.";
|
||||
@ -86,17 +90,17 @@ interpretModulesSearch( const bool debugMode, const QStringList& rawPaths, QStri
|
||||
// module search path in the build dir.
|
||||
if ( debugMode )
|
||||
{
|
||||
QString buildDirModules = QDir::current().absolutePath() +
|
||||
QDir::separator() + "src" +
|
||||
QDir::separator() + "modules";
|
||||
QString buildDirModules
|
||||
= QDir::current().absolutePath() + QDir::separator() + "src" + QDir::separator() + "modules";
|
||||
if ( QDir( buildDirModules ).exists() )
|
||||
{
|
||||
output.append( buildDirModules );
|
||||
}
|
||||
}
|
||||
|
||||
// Install path is set in CalamaresAddPlugin.cmake
|
||||
output.append( CalamaresUtils::systemLibDir().absolutePath() +
|
||||
QDir::separator() + "calamares" +
|
||||
QDir::separator() + "modules" );
|
||||
output.append( CalamaresUtils::systemLibDir().absolutePath() + QDir::separator() + "calamares"
|
||||
+ QDir::separator() + "modules" );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -106,7 +110,9 @@ interpretModulesSearch( const bool debugMode, const QStringList& rawPaths, QStri
|
||||
output.append( d.absolutePath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
cDebug() << Logger::SubEntry << "module-search entry non-existent" << path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,15 +130,17 @@ interpretInstances( const YAML::Node& node, Settings::InstanceDescriptionList& c
|
||||
for ( const QVariant& instancesVListItem : instances )
|
||||
{
|
||||
if ( instancesVListItem.type() != QVariant::Map )
|
||||
{
|
||||
continue;
|
||||
QVariantMap instancesVListItemMap =
|
||||
instancesVListItem.toMap();
|
||||
}
|
||||
QVariantMap instancesVListItemMap = instancesVListItem.toMap();
|
||||
Settings::InstanceDescription instanceMap;
|
||||
for ( auto it = instancesVListItemMap.constBegin();
|
||||
it != instancesVListItemMap.constEnd(); ++it )
|
||||
for ( auto it = instancesVListItemMap.constBegin(); it != instancesVListItemMap.constEnd(); ++it )
|
||||
{
|
||||
if ( it.value().type() != QVariant::String )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
instanceMap.insert( it.key(), it.value().toString() );
|
||||
}
|
||||
customInstances.append( instanceMap );
|
||||
@ -149,37 +157,43 @@ interpretSequence( const YAML::Node& node, Settings::ModuleSequence& moduleSeque
|
||||
{
|
||||
QVariant sequenceV = CalamaresUtils::yamlToVariant( node );
|
||||
if ( !( sequenceV.type() == QVariant::List ) )
|
||||
{
|
||||
throw YAML::Exception( YAML::Mark(), "sequence key does not have a list-value" );
|
||||
}
|
||||
|
||||
const auto sequence = sequenceV.toList();
|
||||
for ( const QVariant& sequenceVListItem : sequence )
|
||||
{
|
||||
if ( sequenceVListItem.type() != QVariant::Map )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString thisActionS = sequenceVListItem.toMap().firstKey();
|
||||
ModuleAction thisAction;
|
||||
if ( thisActionS == "show" )
|
||||
{
|
||||
thisAction = ModuleAction::Show;
|
||||
}
|
||||
else if ( thisActionS == "exec" )
|
||||
{
|
||||
thisAction = ModuleAction::Exec;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList thisActionRoster = sequenceVListItem
|
||||
.toMap()
|
||||
.value( thisActionS )
|
||||
.toStringList();
|
||||
moduleSequence.append( qMakePair( thisAction,
|
||||
thisActionRoster ) );
|
||||
QStringList thisActionRoster = sequenceVListItem.toMap().value( thisActionS ).toStringList();
|
||||
moduleSequence.append( qMakePair( thisAction, thisActionRoster ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw YAML::Exception( YAML::Mark(), "sequence key is missing" );
|
||||
}
|
||||
}
|
||||
|
||||
Settings::Settings( const QString& settingsFilePath,
|
||||
bool debugMode,
|
||||
QObject* parent )
|
||||
Settings::Settings( const QString& settingsFilePath, bool debugMode, QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_debug( debugMode )
|
||||
, m_doChroot( true )
|
||||
@ -198,7 +212,8 @@ Settings::Settings( const QString& settingsFilePath,
|
||||
YAML::Node config = YAML::Load( ba.constData() );
|
||||
Q_ASSERT( config.IsMap() );
|
||||
|
||||
interpretModulesSearch( debugMode, CalamaresUtils::yamlToStringList( config[ "modules-search" ] ), m_modulesSearchPaths );
|
||||
interpretModulesSearch(
|
||||
debugMode, CalamaresUtils::yamlToStringList( config[ "modules-search" ] ), m_modulesSearchPaths );
|
||||
interpretInstances( config[ "instances" ], m_customModuleInstances );
|
||||
interpretSequence( config[ "sequence" ], m_modulesSequence );
|
||||
|
||||
@ -283,4 +298,4 @@ Settings::disableCancelDuringExec() const
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace Calamares
|
||||
|
@ -36,9 +36,7 @@ class DLLEXPORT Settings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Settings( const QString& settingsFilePath,
|
||||
bool debugMode,
|
||||
QObject* parent = nullptr );
|
||||
explicit Settings( const QString& settingsFilePath, bool debugMode, QObject* parent = nullptr );
|
||||
|
||||
static Settings* instance();
|
||||
|
||||
@ -88,6 +86,6 @@ private:
|
||||
bool m_disableCancelDuringExec;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Calamares
|
||||
|
||||
#endif // SETTINGS_H
|
||||
#endif // SETTINGS_H
|
||||
|
Loading…
Reference in New Issue
Block a user