Add optional Python jobmodules support to libcalamaresui.
This commit is contained in:
parent
b924aeef2b
commit
50ba57a33a
@ -21,6 +21,12 @@ list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_UI
|
||||
|
||||
)
|
||||
|
||||
if( WITH_PYTHON )
|
||||
list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES
|
||||
modulesystem/PythonJobModule.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
calamares_add_library( ${CALAMARESUI_LIBRARY_TARGET}
|
||||
SOURCES ${${CALAMARESUI_LIBRARY_TARGET}_SOURCES}
|
||||
UI ${${CALAMARESUI_LIBRARY_TARGET}_UI}
|
||||
|
@ -22,6 +22,11 @@
|
||||
#include "ViewModule.h"
|
||||
#include "utils/YamlUtils.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "CalamaresConfig.h"
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
#include "PythonJobModule.h"
|
||||
#endif
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
@ -106,10 +111,12 @@ Module::fromConfigFile( const QString& path )
|
||||
{
|
||||
m = new ProcessJobModule();
|
||||
}
|
||||
#ifdef WITH_PYTHON
|
||||
else if ( intfString == "python" )
|
||||
{
|
||||
m = nullptr; //TODO: add Python module here
|
||||
m = new PythonJobModule();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( !m )
|
||||
|
82
src/libcalamaresui/modulesystem/PythonJobModule.cpp
Normal file
82
src/libcalamaresui/modulesystem/PythonJobModule.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PythonJobModule.h"
|
||||
|
||||
#include "JobQueue.h"
|
||||
#include "PythonJob.h"
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
|
||||
namespace Calamares {
|
||||
|
||||
|
||||
Module::Type
|
||||
PythonJobModule::type() const
|
||||
{
|
||||
return Job;
|
||||
}
|
||||
|
||||
|
||||
Module::Interface
|
||||
PythonJobModule::interface() const
|
||||
{
|
||||
return Python;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PythonJobModule::loadSelf()
|
||||
{
|
||||
if ( m_loaded )
|
||||
return;
|
||||
|
||||
Calamares::job_ptr j = Calamares::job_ptr( new PythonJob( m_scriptFileName,
|
||||
m_workingPath ) );
|
||||
JobQueue::instance()->enqueue( j );
|
||||
m_loaded = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PythonJobModule::initFrom( const YAML::Node& node )
|
||||
{
|
||||
Module::initFrom( node );
|
||||
QDir directory( location() );
|
||||
m_workingPath = directory.absolutePath();
|
||||
|
||||
if ( node[ "script" ] )
|
||||
{
|
||||
m_scriptFileName = QString::fromStdString( node[ "script" ].as< std::string >() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PythonJobModule::PythonJobModule()
|
||||
: Module()
|
||||
{}
|
||||
|
||||
|
||||
PythonJobModule::~PythonJobModule()
|
||||
{}
|
||||
|
||||
|
||||
} // namespace Calamares
|
50
src/libcalamaresui/modulesystem/PythonJobModule.h
Normal file
50
src/libcalamaresui/modulesystem/PythonJobModule.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CALAMARES_PYTHONJOBMODULE_H
|
||||
#define CALAMARES_PYTHONJOBMODULE_H
|
||||
|
||||
#include "Module.h"
|
||||
|
||||
#include "UiDllMacro.h"
|
||||
|
||||
namespace Calamares {
|
||||
|
||||
class UIDLLEXPORT PythonJobModule : public Module
|
||||
{
|
||||
public:
|
||||
Type type() const override;
|
||||
Interface interface() const override;
|
||||
|
||||
void loadSelf() override;
|
||||
|
||||
protected:
|
||||
void initFrom( const YAML::Node &node ) override;
|
||||
|
||||
private:
|
||||
friend class Module;
|
||||
explicit PythonJobModule();
|
||||
virtual ~PythonJobModule();
|
||||
|
||||
QString m_scriptFileName;
|
||||
QString m_workingPath;
|
||||
};
|
||||
|
||||
} // namespace Calamares
|
||||
|
||||
#endif // CALAMARES_PYTHONJOBMODULE_H
|
Loading…
Reference in New Issue
Block a user