diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index 32e019eb0..1955b64fc 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -228,6 +228,7 @@ PythonJob::PythonJob( const QString& scriptFile, : Job( parent ) , m_scriptFile( scriptFile ) , m_workingPath( workingPath ) + , m_description() , m_configurationMap( moduleConfiguration ) { } @@ -247,8 +248,11 @@ PythonJob::prettyName() const QString PythonJob::prettyStatusMessage() const { - return tr( "Running %1 operation." ) - .arg( QDir( m_workingPath ).dirName() ); + if ( m_description.isEmpty() ) + return tr( "Running %1 operation." ) + .arg( QDir( m_workingPath ).dirName() ); + else + return m_description; } @@ -293,6 +297,17 @@ PythonJob::exec() scriptNamespace ); 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(); diff --git a/src/libcalamares/PythonJob.h b/src/libcalamares/PythonJob.h index 9bc9ddb0b..d13705ed8 100644 --- a/src/libcalamares/PythonJob.h +++ b/src/libcalamares/PythonJob.h @@ -53,6 +53,7 @@ private: CalamaresPython::Helper* helper(); QString m_scriptFile; QString m_workingPath; + QString m_description; QVariantMap m_configurationMap; }; diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 6f19d36a4..09386d58c 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -82,12 +82,14 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor, { m = new ViewModule(); } -#ifdef WITH_PYTHONQT else if ( intfString == "pythonqt" ) { +#ifdef WITH_PYTHONQT m = new PythonQtViewModule(); - } +#else + cLog() << "PythonQt modules are not supported in this version of Calamares."; #endif + } } else if ( typeString == "job" ) { @@ -99,17 +101,20 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor, { m = new ProcessJobModule(); } -#ifdef WITH_PYTHON else if ( intfString == "python" ) { +#ifdef WITH_PYTHON m = new PythonJobModule(); - } +#else + cLog() << "Python modules are not supported in this version of Calamares."; #endif + } } if ( !m ) { - cLog() << Q_FUNC_INFO << "bad module type or interface string" - << instanceId << typeString << intfString; + cLog() << "Bad module type (" << typeString + << ") or interface string (" << intfString + << ") for module " << instanceId; return nullptr; } diff --git a/src/modules/dummypython/main.py b/src/modules/dummypython/main.py index 4a68cf963..29837ba96 100644 --- a/src/modules/dummypython/main.py +++ b/src/modules/dummypython/main.py @@ -19,22 +19,22 @@ # You should have received a copy of the GNU General Public License # along with Calamares. If not, see . +""" +=== 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 os from time import gmtime, strftime, sleep def run(): - """ - 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: - """ + """Dummy python job.""" os.system("/bin/sh -c \"touch ~/calamares-dummypython\"") accumulator = strftime("%Y-%m-%d %H:%M:%S", gmtime()) + "\n" accumulator += "Calamares version: " + libcalamares.VERSION_SHORT + "\n" diff --git a/src/modules/hwclock/main.py b/src/modules/hwclock/main.py index bfb3d1df7..8b31080dd 100644 --- a/src/modules/hwclock/main.py +++ b/src/modules/hwclock/main.py @@ -28,7 +28,7 @@ import libcalamares def run(): """ - Set hardware clock + Set hardware clock. """ root_mount_point = libcalamares.globalstorage.value("rootMountPoint") diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index c0970ddfe..9eaa5c622 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -263,22 +263,7 @@ class UnpackOperation: def run(): """ - Unsquashes filesystem from given image file. - - 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: + Unsquash filesystem. """ PATH_PROCFS = '/proc/filesystems' diff --git a/src/modules/unpackfs/unpackfs.conf b/src/modules/unpackfs/unpackfs.conf index 68de113b5..34e7bc48d 100644 --- a/src/modules/unpackfs/unpackfs.conf +++ b/src/modules/unpackfs/unpackfs.conf @@ -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: +# 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" sourcefs: "ext4" destination: ""