Consistency: calamares_main ==> run; global_storage => globalStorage
This commit is contained in:
parent
fb6d80ccb6
commit
beafcd9cc4
@ -120,13 +120,13 @@ PythonJob::exec()
|
|||||||
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
|
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
|
||||||
|
|
||||||
calamaresNamespace[ "job" ] = CalamaresPython::PythonJobInterface( this );
|
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(),
|
bp::object result = bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(),
|
||||||
scriptNamespace,
|
scriptNamespace,
|
||||||
scriptNamespace );
|
scriptNamespace );
|
||||||
|
|
||||||
bp::object entryPoint = scriptNamespace[ "calamares_main" ];
|
bp::object entryPoint = scriptNamespace[ "run" ];
|
||||||
|
|
||||||
QString message = QString::fromStdString( bp::extract< std::string >( entryPoint() ) );
|
QString message = QString::fromStdString( bp::extract< std::string >( entryPoint() ) );
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import libcalamares
|
|||||||
import os
|
import os
|
||||||
from time import gmtime, strftime
|
from time import gmtime, strftime
|
||||||
|
|
||||||
def calamares_main():
|
def run():
|
||||||
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.shortVersion + "\n"
|
accumulator += "Calamares version: " + libcalamares.shortVersion + "\n"
|
||||||
@ -29,16 +29,16 @@ def calamares_main():
|
|||||||
accumulator += "This job's path: " + libcalamares.job.workingPath + "\n"
|
accumulator += "This job's path: " + libcalamares.job.workingPath + "\n"
|
||||||
accumulator += str( libcalamares.job.configuration )
|
accumulator += str( libcalamares.job.configuration )
|
||||||
accumulator += " *** GlobalStorage test ***\n"
|
accumulator += " *** GlobalStorage test ***\n"
|
||||||
accumulator += "lala: " + str( libcalamares.global_storage.contains( "lala" ) ) + "\n"
|
accumulator += "lala: " + str( libcalamares.globalStorage.contains( "lala" ) ) + "\n"
|
||||||
accumulator += "foo: " + str( libcalamares.global_storage.contains( "foo" ) ) + "\n"
|
accumulator += "foo: " + str( libcalamares.globalStorage.contains( "foo" ) ) + "\n"
|
||||||
accumulator += "count: " + str( libcalamares.global_storage.count() ) + "\n"
|
accumulator += "count: " + str( libcalamares.globalStorage.count() ) + "\n"
|
||||||
libcalamares.global_storage.insert( "item2", "value2" )
|
libcalamares.globalStorage.insert( "item2", "value2" )
|
||||||
libcalamares.global_storage.insert( "item3", 3 )
|
libcalamares.globalStorage.insert( "item3", 3 )
|
||||||
accumulator += "keys: " + str( libcalamares.global_storage.keys() ) + "\n"
|
accumulator += "keys: " + str( libcalamares.globalStorage.keys() ) + "\n"
|
||||||
accumulator += "remove: " + str( libcalamares.global_storage.remove( "item2" ) ) + "\n"
|
accumulator += "remove: " + str( libcalamares.globalStorage.remove( "item2" ) ) + "\n"
|
||||||
accumulator += "values: " + str( libcalamares.global_storage.value( "foo" ) )+ " "\
|
accumulator += "values: " + str( libcalamares.globalStorage.value( "foo" ) )+ " "\
|
||||||
+ str( libcalamares.global_storage.value( "item2" ) ) + " "\
|
+ str( libcalamares.globalStorage.value( "item2" ) ) + " "\
|
||||||
+ str( libcalamares.global_storage.value( "item3" ) ) + "\n"
|
+ str( libcalamares.globalStorage.value( "item3" ) ) + "\n"
|
||||||
|
|
||||||
libcalamares.job.setprogress( 0.1 )
|
libcalamares.job.setprogress( 0.1 )
|
||||||
return accumulator
|
return accumulator
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
syntax: "YAML map of anything"
|
syntax: "YAML map of anything"
|
||||||
example:
|
example:
|
||||||
whats_this: "fake global storage contents"
|
whats_this: "fake global storage contents"
|
||||||
from_where: "global_storage.yaml"
|
from_where: "globalStorage.yaml"
|
||||||
a_list:
|
a_list:
|
||||||
- "item1"
|
- "item1"
|
||||||
- "item2"
|
- "item2"
|
||||||
@ -15,4 +15,4 @@ a_list_of_maps:
|
|||||||
- "another element"
|
- "another element"
|
||||||
- name: "another item"
|
- name: "another item"
|
||||||
contents:
|
contents:
|
||||||
- "not much"
|
- "not much"
|
@ -68,9 +68,9 @@ def installGrub( rootMountPoint, bootLoader ):
|
|||||||
chroot_call( rootMountPoint, [ "grub-mkconfig", "-o", "/boot/grub/grub.cfg" ] )
|
chroot_call( rootMountPoint, [ "grub-mkconfig", "-o", "/boot/grub/grub.cfg" ] )
|
||||||
|
|
||||||
|
|
||||||
def calamares_main():
|
def run():
|
||||||
rootMountPoint = libcalamares.global_storage.value( "rootMountPoint" )
|
rootMountPoint = libcalamares.globalStorage.value( "rootMountPoint" )
|
||||||
bootLoader = libcalamares.global_storage.value( "bootLoader" )
|
bootLoader = libcalamares.globalStorage.value( "bootLoader" )
|
||||||
extraMounts = libcalamares.job.configuration[ "extraMounts" ]
|
extraMounts = libcalamares.job.configuration[ "extraMounts" ]
|
||||||
mountPartitions( rootMountPoint, extraMounts )
|
mountPartitions( rootMountPoint, extraMounts )
|
||||||
try:
|
try:
|
||||||
|
@ -52,13 +52,13 @@ def mountPartitions( rootMountPoint, partitions ):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def calamares_main():
|
def run():
|
||||||
rootMountPoint = tempfile.mkdtemp( prefix="calamares-root-" )
|
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
|
# Sort by mount points to ensure / is mounted before the rest
|
||||||
partitions.sort( key = lambda x: x[ "mountPoint" ] )
|
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 )
|
return "All done, mounted at {}".format( rootMountPoint )
|
||||||
|
@ -30,6 +30,7 @@ except ImportError:
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Job:
|
class Job:
|
||||||
def __init__( self, workingPath, doc ):
|
def __init__( self, workingPath, doc ):
|
||||||
self.prettyName = "Testing job " + doc[ "name" ]
|
self.prettyName = "Testing job " + doc[ "name" ]
|
||||||
@ -37,7 +38,8 @@ class Job:
|
|||||||
self.configuration = doc[ "configuration" ]
|
self.configuration = doc[ "configuration" ]
|
||||||
|
|
||||||
def setprogress( self, progress ):
|
def setprogress( self, progress ):
|
||||||
print ( "Job set progress to {}%.".format( progress * 100 ) )
|
print( "Job set progress to {}%.".format( progress * 100 ) )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -59,21 +61,21 @@ def main():
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
libcalamares.job = Job( args.moduledir, doc )
|
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:
|
if args.globalstorage_yaml:
|
||||||
with open( args.globalstorage_yaml ) as f:
|
with open( args.globalstorage_yaml ) as f:
|
||||||
doc = yaml.load( f )
|
doc = yaml.load( f )
|
||||||
for key, value in doc.items():
|
for key, value in doc.items():
|
||||||
libcalamares.global_storage.insert( key, value )
|
libcalamares.globalStorage.insert( key, value )
|
||||||
|
|
||||||
scriptpath = os.path.abspath( args.moduledir )
|
scriptpath = os.path.abspath( args.moduledir )
|
||||||
sys.path.append( scriptpath )
|
sys.path.append( scriptpath )
|
||||||
import main
|
import main
|
||||||
|
|
||||||
print( "Output from module:" )
|
print( "Output from module:" )
|
||||||
print( main.calamares_main() )
|
print( main.run() )
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ def listMounts( rootMountPoint ):
|
|||||||
return lst
|
return lst
|
||||||
|
|
||||||
|
|
||||||
def calamares_main():
|
def run():
|
||||||
rootMountPoint = libcalamares.global_storage.value( "rootMountPoint" )
|
rootMountPoint = libcalamares.globalStorage.value( "rootMountPoint" )
|
||||||
if not rootMountPoint:
|
if not rootMountPoint:
|
||||||
return "GlobalStorage does not contain a \"rootMountPoint\" key, doing nothing"
|
return "GlobalStorage does not contain a \"rootMountPoint\" key, doing nothing"
|
||||||
if not os.path.exists( rootMountPoint ):
|
if not os.path.exists( rootMountPoint ):
|
||||||
|
Loading…
Reference in New Issue
Block a user