[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:
parent
fe61925f31
commit
517dbfab06
@ -233,7 +233,7 @@ Helper::~Helper()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
boost::python::object
|
boost::python::dict
|
||||||
Helper::createCleanNamespace()
|
Helper::createCleanNamespace()
|
||||||
{
|
{
|
||||||
// To make sure we run each script with a clean namespace, we only fetch the
|
// To make sure we run each script with a clean namespace, we only fetch the
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
explicit Helper( QObject* parent = nullptr );
|
explicit Helper( QObject* parent = nullptr );
|
||||||
virtual ~Helper();
|
virtual ~Helper();
|
||||||
|
|
||||||
boost::python::object createCleanNamespace();
|
boost::python::dict createCleanNamespace();
|
||||||
|
|
||||||
QString handleLastError();
|
QString handleLastError();
|
||||||
|
|
||||||
|
@ -216,10 +216,10 @@ BOOST_PYTHON_MODULE( libcalamares )
|
|||||||
"in the original string."
|
"in the original string."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
bp::def(
|
bp::def(
|
||||||
"gettext_languages",
|
"gettext_languages",
|
||||||
&CalamaresPython::gettext_languages,
|
&CalamaresPython::gettext_languages,
|
||||||
"Returns list of languages (most to least-specific) for gettext."
|
"Returns list of languages (most to least-specific) for gettext."
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ PythonJob::exec()
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bp::object scriptNamespace = helper()->createCleanNamespace();
|
bp::dict scriptNamespace = helper()->createCleanNamespace();
|
||||||
|
|
||||||
bp::object calamaresModule = bp::import( "libcalamares" );
|
bp::object calamaresModule = bp::import( "libcalamares" );
|
||||||
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
|
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
|
||||||
@ -310,7 +310,7 @@ PythonJob::exec()
|
|||||||
scriptNamespace );
|
scriptNamespace );
|
||||||
|
|
||||||
bp::object entryPoint = scriptNamespace[ "run" ];
|
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();
|
cDebug() << "Job file" << scriptFI.absoluteFilePath();
|
||||||
if ( !prettyNameFunc.is_none() )
|
if ( !prettyNameFunc.is_none() )
|
||||||
|
Loading…
Reference in New Issue
Block a user