[libcalamares] The script namespace is actually a dict

Use dict methods, in particular d.get(k, v), to retrieve
the pretty_name() function (or None if it isn't there).
Using getattr() on a dict will not return values in the
dict.
This commit is contained in:
Adriaan de Groot 2017-12-01 16:42:56 -05:00
parent fe61925f31
commit 517dbfab06
3 changed files with 8 additions and 8 deletions

View File

@ -233,7 +233,7 @@ Helper::~Helper()
{}
boost::python::object
boost::python::dict
Helper::createCleanNamespace()
{
// To make sure we run each script with a clean namespace, we only fetch the

View File

@ -51,7 +51,7 @@ public:
explicit Helper( QObject* parent = nullptr );
virtual ~Helper();
boost::python::object createCleanNamespace();
boost::python::dict createCleanNamespace();
QString handleLastError();

View File

@ -296,7 +296,7 @@ PythonJob::exec()
try
{
bp::object scriptNamespace = helper()->createCleanNamespace();
bp::dict scriptNamespace = helper()->createCleanNamespace();
bp::object calamaresModule = bp::import( "libcalamares" );
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
@ -310,7 +310,7 @@ PythonJob::exec()
scriptNamespace );
bp::object entryPoint = scriptNamespace[ "run" ];
bp::object prettyNameFunc = bp::getattr(scriptNamespace, "pretty_name", bp::object());
bp::object prettyNameFunc = scriptNamespace.get("pretty_name", bp::object());
cDebug() << "Job file" << scriptFI.absoluteFilePath();
if ( !prettyNameFunc.is_none() )