CalamaresPrivate ==> CalamaresPython
This commit is contained in:
parent
568f2abd0b
commit
2f03dfa43b
@ -38,7 +38,7 @@ public:
|
|||||||
, m_queue( queue )
|
, m_queue( queue )
|
||||||
{
|
{
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
new CalamaresPrivate::PythonJobHelper( this );
|
new CalamaresPython::Helper( this );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ BOOST_PYTHON_MODULE( libcalamares )
|
|||||||
bp::scope().attr( "VERSION" ) = CALAMARES_VERSION;
|
bp::scope().attr( "VERSION" ) = CALAMARES_VERSION;
|
||||||
bp::scope().attr( "VERSION_SHORT" ) = CALAMARES_VERSION_SHORT;
|
bp::scope().attr( "VERSION_SHORT" ) = CALAMARES_VERSION_SHORT;
|
||||||
|
|
||||||
bp::class_< CalamaresPrivate::PythonJobInterface >( "job", bp::init< const Calamares::PythonJob* >() )
|
bp::class_< CalamaresPython::PythonJobInterface >( "job", bp::init< const Calamares::PythonJob* >() )
|
||||||
.def( "prettyName", &CalamaresPrivate::PythonJobInterface::prettyName )
|
.def( "prettyName", &CalamaresPython::PythonJobInterface::prettyName )
|
||||||
.def( "workingPath", &CalamaresPrivate::PythonJobInterface::workingPath );
|
.def( "workingPath", &CalamaresPython::PythonJobInterface::workingPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ PythonJob::exec()
|
|||||||
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__" ) );
|
||||||
|
|
||||||
calamaresNamespace[ "job" ] = CalamaresPrivate::PythonJobInterface( this );
|
calamaresNamespace[ "job" ] = CalamaresPython::PythonJobInterface( this );
|
||||||
|
|
||||||
bp::object result = bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(),
|
bp::object result = bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(),
|
||||||
scriptNamespace,
|
scriptNamespace,
|
||||||
@ -134,10 +134,10 @@ PythonJob::exec()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CalamaresPrivate::PythonJobHelper*
|
CalamaresPython::Helper*
|
||||||
PythonJob::helper()
|
PythonJob::helper()
|
||||||
{
|
{
|
||||||
return CalamaresPrivate::PythonJobHelper::s_instance;
|
return CalamaresPython::Helper::s_instance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
#include "Job.h"
|
#include "Job.h"
|
||||||
|
|
||||||
namespace CalamaresPrivate
|
namespace CalamaresPython
|
||||||
{
|
{
|
||||||
class PythonJobInterface;
|
class PythonJobInterface;
|
||||||
class PythonJobHelper;
|
class Helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Calamares {
|
namespace Calamares {
|
||||||
@ -42,9 +42,9 @@ public:
|
|||||||
JobResult exec() override;
|
JobResult exec() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class CalamaresPrivate::PythonJobHelper;
|
friend class CalamaresPython::Helper;
|
||||||
friend class CalamaresPrivate::PythonJobInterface;
|
friend class CalamaresPython::PythonJobInterface;
|
||||||
CalamaresPrivate::PythonJobHelper* helper();
|
CalamaresPython::Helper* helper();
|
||||||
QString m_scriptFile;
|
QString m_scriptFile;
|
||||||
QString m_workingPath;
|
QString m_workingPath;
|
||||||
};
|
};
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "PythonJobApi.h"
|
#include "PythonJobApi.h"
|
||||||
|
|
||||||
|
|
||||||
namespace CalamaresPrivate
|
namespace CalamaresPython
|
||||||
{
|
{
|
||||||
|
|
||||||
PythonJobInterface::PythonJobInterface( const Calamares::PythonJob* parent )
|
PythonJobInterface::PythonJobInterface( const Calamares::PythonJob* parent )
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "PythonJob.h"
|
#include "PythonJob.h"
|
||||||
|
|
||||||
namespace CalamaresPrivate
|
namespace CalamaresPython
|
||||||
{
|
{
|
||||||
|
|
||||||
class PythonJobInterface
|
class PythonJobInterface
|
||||||
|
@ -29,11 +29,11 @@
|
|||||||
|
|
||||||
namespace bp = boost::python;
|
namespace bp = boost::python;
|
||||||
|
|
||||||
namespace CalamaresPrivate {
|
namespace CalamaresPython {
|
||||||
|
|
||||||
PythonJobHelper* PythonJobHelper::s_instance = nullptr;
|
Helper* Helper::s_instance = nullptr;
|
||||||
|
|
||||||
PythonJobHelper::PythonJobHelper( QObject* parent )
|
Helper::Helper( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
{
|
{
|
||||||
// Let's make extra sure we only call Py_Initialize once
|
// Let's make extra sure we only call Py_Initialize once
|
||||||
@ -81,12 +81,12 @@ PythonJobHelper::PythonJobHelper( QObject* parent )
|
|||||||
s_instance = this;
|
s_instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
PythonJobHelper::~PythonJobHelper()
|
Helper::~Helper()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
boost::python::object
|
boost::python::object
|
||||||
PythonJobHelper::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
|
||||||
// builtin namespace from the interpreter as it was when freshly initialized.
|
// builtin namespace from the interpreter as it was when freshly initialized.
|
||||||
@ -98,7 +98,7 @@ PythonJobHelper::createCleanNamespace()
|
|||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
PythonJobHelper::handleLastError()
|
Helper::handleLastError()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
@ -26,22 +26,22 @@
|
|||||||
#undef slots
|
#undef slots
|
||||||
#include <boost/python/object.hpp>
|
#include <boost/python/object.hpp>
|
||||||
|
|
||||||
namespace CalamaresPrivate {
|
namespace CalamaresPython {
|
||||||
|
|
||||||
class PythonJobHelper : public QObject
|
class Helper : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PythonJobHelper( QObject* parent = nullptr );
|
explicit Helper( QObject* parent = nullptr );
|
||||||
virtual ~PythonJobHelper();
|
virtual ~Helper();
|
||||||
|
|
||||||
boost::python::object createCleanNamespace();
|
boost::python::object createCleanNamespace();
|
||||||
|
|
||||||
QString handleLastError();
|
QString handleLastError();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend PythonJobHelper* Calamares::PythonJob::helper();
|
friend Helper* Calamares::PythonJob::helper();
|
||||||
static PythonJobHelper* s_instance;
|
static Helper* s_instance;
|
||||||
|
|
||||||
boost::python::object m_mainModule;
|
boost::python::object m_mainModule;
|
||||||
boost::python::object m_mainNamespace;
|
boost::python::object m_mainNamespace;
|
||||||
|
@ -39,12 +39,10 @@
|
|||||||
// Example module.conf
|
// Example module.conf
|
||||||
/*
|
/*
|
||||||
---
|
---
|
||||||
type: "core" #core or view
|
type: "view" #job or view
|
||||||
name: "foo" #the module name. must be unique and same as the parent directory
|
name: "foo" #the module name. must be unique and same as the parent directory
|
||||||
interface: "qtplugin" #can be: qtplugin, python, process, ...
|
interface: "qtplugin" #can be: qtplugin, python, process, ...
|
||||||
requires: [] #list of module names that must also be loaded. only applies to
|
requires: [] #list of module names that must also be loaded before this one
|
||||||
#binary plugins! these are actual link-time dependencies, not
|
|
||||||
#conceptual dependencies for the setup procedure
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user