From beafcd9cc4182d60c5b4aefade2f727df9979178 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Fri, 25 Jul 2014 16:41:21 +0200 Subject: [PATCH] Consistency: calamares_main ==> run; global_storage => globalStorage --- src/libcalamares/PythonJob.cpp | 4 ++-- src/modules/dummypython/main.py | 22 +++++++++---------- ...global_storage.yaml => globalStorage.yaml} | 4 ++-- src/modules/grub/main.py | 6 ++--- src/modules/mount/main.py | 8 +++---- src/modules/testmodule.py | 12 +++++----- src/modules/umount/main.py | 4 ++-- 7 files changed, 31 insertions(+), 29 deletions(-) rename src/modules/{global_storage.yaml => globalStorage.yaml} (83%) diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index 6772974d7..3b09759ae 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -120,13 +120,13 @@ PythonJob::exec() bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) ); calamaresNamespace[ "job" ] = CalamaresPython::PythonJobInterface( this ); - calamaresNamespace[ "global_storage" ] = bp::ptr( JobQueue::instance()->globalStorage() ); + calamaresNamespace[ "globalStorage" ] = bp::ptr( JobQueue::instance()->globalStorage() ); bp::object result = bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(), scriptNamespace, scriptNamespace ); - bp::object entryPoint = scriptNamespace[ "calamares_main" ]; + bp::object entryPoint = scriptNamespace[ "run" ]; QString message = QString::fromStdString( bp::extract< std::string >( entryPoint() ) ); diff --git a/src/modules/dummypython/main.py b/src/modules/dummypython/main.py index b9435f145..c173c294d 100644 --- a/src/modules/dummypython/main.py +++ b/src/modules/dummypython/main.py @@ -21,7 +21,7 @@ import libcalamares import os from time import gmtime, strftime -def calamares_main(): +def run(): os.system( "/bin/sh -c \"touch ~/calamares-dummypython\"" ) accumulator = strftime( "%Y-%m-%d %H:%M:%S", gmtime() ) + "\n" accumulator += "Calamares version: " + libcalamares.shortVersion + "\n" @@ -29,16 +29,16 @@ def calamares_main(): accumulator += "This job's path: " + libcalamares.job.workingPath + "\n" accumulator += str( libcalamares.job.configuration ) accumulator += " *** GlobalStorage test ***\n" - accumulator += "lala: " + str( libcalamares.global_storage.contains( "lala" ) ) + "\n" - accumulator += "foo: " + str( libcalamares.global_storage.contains( "foo" ) ) + "\n" - accumulator += "count: " + str( libcalamares.global_storage.count() ) + "\n" - libcalamares.global_storage.insert( "item2", "value2" ) - libcalamares.global_storage.insert( "item3", 3 ) - accumulator += "keys: " + str( libcalamares.global_storage.keys() ) + "\n" - accumulator += "remove: " + str( libcalamares.global_storage.remove( "item2" ) ) + "\n" - accumulator += "values: " + str( libcalamares.global_storage.value( "foo" ) )+ " "\ - + str( libcalamares.global_storage.value( "item2" ) ) + " "\ - + str( libcalamares.global_storage.value( "item3" ) ) + "\n" + accumulator += "lala: " + str( libcalamares.globalStorage.contains( "lala" ) ) + "\n" + accumulator += "foo: " + str( libcalamares.globalStorage.contains( "foo" ) ) + "\n" + accumulator += "count: " + str( libcalamares.globalStorage.count() ) + "\n" + libcalamares.globalStorage.insert( "item2", "value2" ) + libcalamares.globalStorage.insert( "item3", 3 ) + accumulator += "keys: " + str( libcalamares.globalStorage.keys() ) + "\n" + accumulator += "remove: " + str( libcalamares.globalStorage.remove( "item2" ) ) + "\n" + accumulator += "values: " + str( libcalamares.globalStorage.value( "foo" ) )+ " "\ + + str( libcalamares.globalStorage.value( "item2" ) ) + " "\ + + str( libcalamares.globalStorage.value( "item3" ) ) + "\n" libcalamares.job.setprogress( 0.1 ) return accumulator diff --git a/src/modules/global_storage.yaml b/src/modules/globalStorage.yaml similarity index 83% rename from src/modules/global_storage.yaml rename to src/modules/globalStorage.yaml index 2bb7e744d..1187fe93a 100644 --- a/src/modules/global_storage.yaml +++ b/src/modules/globalStorage.yaml @@ -2,7 +2,7 @@ syntax: "YAML map of anything" example: whats_this: "fake global storage contents" - from_where: "global_storage.yaml" + from_where: "globalStorage.yaml" a_list: - "item1" - "item2" @@ -15,4 +15,4 @@ a_list_of_maps: - "another element" - name: "another item" contents: - - "not much" \ No newline at end of file + - "not much" diff --git a/src/modules/grub/main.py b/src/modules/grub/main.py index b365821a5..d735f0681 100644 --- a/src/modules/grub/main.py +++ b/src/modules/grub/main.py @@ -68,9 +68,9 @@ def installGrub( rootMountPoint, bootLoader ): chroot_call( rootMountPoint, [ "grub-mkconfig", "-o", "/boot/grub/grub.cfg" ] ) -def calamares_main(): - rootMountPoint = libcalamares.global_storage.value( "rootMountPoint" ) - bootLoader = libcalamares.global_storage.value( "bootLoader" ) +def run(): + rootMountPoint = libcalamares.globalStorage.value( "rootMountPoint" ) + bootLoader = libcalamares.globalStorage.value( "bootLoader" ) extraMounts = libcalamares.job.configuration[ "extraMounts" ] mountPartitions( rootMountPoint, extraMounts ) try: diff --git a/src/modules/mount/main.py b/src/modules/mount/main.py index 1ba8c563a..8fc928f5b 100644 --- a/src/modules/mount/main.py +++ b/src/modules/mount/main.py @@ -52,13 +52,13 @@ def mountPartitions( rootMountPoint, partitions ): ) -def calamares_main(): +def run(): rootMountPoint = tempfile.mkdtemp( prefix="calamares-root-" ) - partitions = libcalamares.global_storage.value( "partitions" ) + partitions = libcalamares.globalStorage.value( "partitions" ) # Sort by mount points to ensure / is mounted before the rest partitions.sort( key = lambda x: x[ "mountPoint" ] ) - mountPartitions( rootMountPoint, libcalamares.global_storage.value( "partitions" ) ) + mountPartitions( rootMountPoint, libcalamares.globalStorage.value( "partitions" ) ) - libcalamares.global_storage.insert( "rootMountPoint", rootMountPoint ) + libcalamares.globalStorage.insert( "rootMountPoint", rootMountPoint ) return "All done, mounted at {}".format( rootMountPoint ) diff --git a/src/modules/testmodule.py b/src/modules/testmodule.py index ff6daa0aa..f96fe371d 100755 --- a/src/modules/testmodule.py +++ b/src/modules/testmodule.py @@ -30,6 +30,7 @@ except ImportError: raise + class Job: def __init__( self, workingPath, doc ): self.prettyName = "Testing job " + doc[ "name" ] @@ -37,7 +38,8 @@ class Job: self.configuration = doc[ "configuration" ] def setprogress( self, progress ): - print ( "Job set progress to {}%.".format( progress * 100 ) ) + print( "Job set progress to {}%.".format( progress * 100 ) ) + def main(): @@ -59,21 +61,21 @@ def main(): return 1 libcalamares.job = Job( args.moduledir, doc ) - libcalamares.global_storage = libcalamares.GlobalStorage() + libcalamares.globalStorage = libcalamares.GlobalStorage() - # if a file for simulating global_storage contents is provided, load it + # if a file for simulating globalStorage contents is provided, load it if args.globalstorage_yaml: with open( args.globalstorage_yaml ) as f: doc = yaml.load( f ) for key, value in doc.items(): - libcalamares.global_storage.insert( key, value ) + libcalamares.globalStorage.insert( key, value ) scriptpath = os.path.abspath( args.moduledir ) sys.path.append( scriptpath ) import main print( "Output from module:" ) - print( main.calamares_main() ) + print( main.run() ) return 0 diff --git a/src/modules/umount/main.py b/src/modules/umount/main.py index 8c51a2d2c..5817a95b5 100644 --- a/src/modules/umount/main.py +++ b/src/modules/umount/main.py @@ -32,8 +32,8 @@ def listMounts( rootMountPoint ): return lst -def calamares_main(): - rootMountPoint = libcalamares.global_storage.value( "rootMountPoint" ) +def run(): + rootMountPoint = libcalamares.globalStorage.value( "rootMountPoint" ) if not rootMountPoint: return "GlobalStorage does not contain a \"rootMountPoint\" key, doing nothing" if not os.path.exists( rootMountPoint ):