Merge branch 'python-bits'
This commit is contained in:
commit
8ca94db0fa
@ -228,6 +228,7 @@ PythonJob::PythonJob( const QString& scriptFile,
|
|||||||
: Job( parent )
|
: Job( parent )
|
||||||
, m_scriptFile( scriptFile )
|
, m_scriptFile( scriptFile )
|
||||||
, m_workingPath( workingPath )
|
, m_workingPath( workingPath )
|
||||||
|
, m_description()
|
||||||
, m_configurationMap( moduleConfiguration )
|
, m_configurationMap( moduleConfiguration )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -247,8 +248,11 @@ PythonJob::prettyName() const
|
|||||||
QString
|
QString
|
||||||
PythonJob::prettyStatusMessage() const
|
PythonJob::prettyStatusMessage() const
|
||||||
{
|
{
|
||||||
return tr( "Running %1 operation." )
|
if ( m_description.isEmpty() )
|
||||||
.arg( QDir( m_workingPath ).dirName() );
|
return tr( "Running %1 operation." )
|
||||||
|
.arg( QDir( m_workingPath ).dirName() );
|
||||||
|
else
|
||||||
|
return m_description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -293,6 +297,17 @@ PythonJob::exec()
|
|||||||
scriptNamespace );
|
scriptNamespace );
|
||||||
|
|
||||||
bp::object entryPoint = scriptNamespace[ "run" ];
|
bp::object entryPoint = scriptNamespace[ "run" ];
|
||||||
|
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');
|
||||||
|
if ( i_newline > 0 )
|
||||||
|
m_description.truncate( i_newline );
|
||||||
|
cDebug() << "Job" << prettyName() << "->" << m_description;
|
||||||
|
emit progress( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
bp::object runResult = entryPoint();
|
bp::object runResult = entryPoint();
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ private:
|
|||||||
CalamaresPython::Helper* helper();
|
CalamaresPython::Helper* helper();
|
||||||
QString m_scriptFile;
|
QString m_scriptFile;
|
||||||
QString m_workingPath;
|
QString m_workingPath;
|
||||||
|
QString m_description;
|
||||||
QVariantMap m_configurationMap;
|
QVariantMap m_configurationMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,12 +82,14 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
|
|||||||
{
|
{
|
||||||
m = new ViewModule();
|
m = new ViewModule();
|
||||||
}
|
}
|
||||||
#ifdef WITH_PYTHONQT
|
|
||||||
else if ( intfString == "pythonqt" )
|
else if ( intfString == "pythonqt" )
|
||||||
{
|
{
|
||||||
|
#ifdef WITH_PYTHONQT
|
||||||
m = new PythonQtViewModule();
|
m = new PythonQtViewModule();
|
||||||
}
|
#else
|
||||||
|
cLog() << "PythonQt modules are not supported in this version of Calamares.";
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( typeString == "job" )
|
else if ( typeString == "job" )
|
||||||
{
|
{
|
||||||
@ -99,17 +101,20 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
|
|||||||
{
|
{
|
||||||
m = new ProcessJobModule();
|
m = new ProcessJobModule();
|
||||||
}
|
}
|
||||||
#ifdef WITH_PYTHON
|
|
||||||
else if ( intfString == "python" )
|
else if ( intfString == "python" )
|
||||||
{
|
{
|
||||||
|
#ifdef WITH_PYTHON
|
||||||
m = new PythonJobModule();
|
m = new PythonJobModule();
|
||||||
}
|
#else
|
||||||
|
cLog() << "Python modules are not supported in this version of Calamares.";
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( !m )
|
if ( !m )
|
||||||
{
|
{
|
||||||
cLog() << Q_FUNC_INFO << "bad module type or interface string"
|
cLog() << "Bad module type (" << typeString
|
||||||
<< instanceId << typeString << intfString;
|
<< ") or interface string (" << intfString
|
||||||
|
<< ") for module " << instanceId;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,22 +19,22 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
"""
|
||||||
|
=== Example Python jobmodule.
|
||||||
|
|
||||||
|
A Python jobmodule is a Python program which imports libcalamares and
|
||||||
|
has a function run() as entry point. run() must return None if everything
|
||||||
|
went well, or a tuple (str,str) with an error message and description
|
||||||
|
if something went wrong.
|
||||||
|
"""
|
||||||
|
|
||||||
import libcalamares
|
import libcalamares
|
||||||
import os
|
import os
|
||||||
from time import gmtime, strftime, sleep
|
from time import gmtime, strftime, sleep
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
"""
|
"""Dummy python job."""
|
||||||
Example Python jobmodule.
|
|
||||||
|
|
||||||
A Python jobmodule is a Python program which imports libcalamares and
|
|
||||||
has a function run() as entry point. run() must return None if everything
|
|
||||||
went well, or a tuple (str,str) with an error message and description
|
|
||||||
if something went wrong.
|
|
||||||
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
os.system("/bin/sh -c \"touch ~/calamares-dummypython\"")
|
os.system("/bin/sh -c \"touch ~/calamares-dummypython\"")
|
||||||
accumulator = strftime("%Y-%m-%d %H:%M:%S", gmtime()) + "\n"
|
accumulator = strftime("%Y-%m-%d %H:%M:%S", gmtime()) + "\n"
|
||||||
accumulator += "Calamares version: " + libcalamares.VERSION_SHORT + "\n"
|
accumulator += "Calamares version: " + libcalamares.VERSION_SHORT + "\n"
|
||||||
|
@ -28,7 +28,7 @@ import libcalamares
|
|||||||
|
|
||||||
def run():
|
def run():
|
||||||
"""
|
"""
|
||||||
Set hardware clock
|
Set hardware clock.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
|
@ -263,22 +263,7 @@ class UnpackOperation:
|
|||||||
|
|
||||||
def run():
|
def run():
|
||||||
"""
|
"""
|
||||||
Unsquashes filesystem from given image file.
|
Unsquash filesystem.
|
||||||
|
|
||||||
from globalstorage: rootMountPoint
|
|
||||||
from job.configuration: the path to where to mount the source image(s) for
|
|
||||||
copying an ordered list of unpack mappings for image file <-> target dir
|
|
||||||
relative to rootMountPoint, e.g.:
|
|
||||||
configuration:
|
|
||||||
unpack:
|
|
||||||
- source: "/path/to/filesystem.img"
|
|
||||||
sourcefs: "ext4"
|
|
||||||
destination: ""
|
|
||||||
- source: "/path/to/another/filesystem.sqfs"
|
|
||||||
sourcefs: "squashfs"
|
|
||||||
destination: ""
|
|
||||||
|
|
||||||
:return:
|
|
||||||
"""
|
"""
|
||||||
PATH_PROCFS = '/proc/filesystems'
|
PATH_PROCFS = '/proc/filesystems'
|
||||||
|
|
||||||
|
@ -1,5 +1,21 @@
|
|||||||
|
# Unsquash / unpack a filesystem. Multiple sources are supported, and
|
||||||
|
# they may be squashed or plain filesystems.
|
||||||
|
#
|
||||||
|
# Configuration:
|
||||||
|
#
|
||||||
|
# from globalstorage: rootMountPoint
|
||||||
|
# from job.configuration: the path to where to mount the source image(s)
|
||||||
|
# for copying an ordered list of unpack mappings for image file <->
|
||||||
|
# target dir relative to rootMountPoint.
|
||||||
|
|
||||||
---
|
---
|
||||||
unpack:
|
unpack:
|
||||||
|
# Each list item is unpacked, in order, to the target system.
|
||||||
|
# Each list item has the following attributes:
|
||||||
|
# source: path relative to the live / intstalling system to the image
|
||||||
|
# sourcefs: ext4 or squashfs (may be others if mount supports is)
|
||||||
|
# destination: path relative to rootMountPoint (so in the target
|
||||||
|
# system) where this filesystem is unpacked.
|
||||||
- source: "/path/to/filesystem.img"
|
- source: "/path/to/filesystem.img"
|
||||||
sourcefs: "ext4"
|
sourcefs: "ext4"
|
||||||
destination: ""
|
destination: ""
|
||||||
|
Loading…
Reference in New Issue
Block a user