[testmodule.py] Simulate global storage contents from a YAML file.

main
Teo Mrnjavac 10 years ago
parent 1b64917385
commit 4881684e18

@ -29,7 +29,7 @@ class Job:
self.workingPath = workingPath self.workingPath = workingPath
self.configuration = doc[ "configuration" ] self.configuration = doc[ "configuration" ]
# Usage: ./testmodule.py <libcalamares.so dir> <python module dir> # Usage: ./testmodule.py <libcalamares.so dir> <python module dir> [global_storage yaml file]
def main( args ): def main( args ):
moduledirpath = os.path.abspath( sys.argv[ 2 ] ) moduledirpath = os.path.abspath( sys.argv[ 2 ] )
print( "Importing libcalamares from: " + libcalamares.__file__ ) print( "Importing libcalamares from: " + libcalamares.__file__ )
@ -47,6 +47,12 @@ def main( args ):
libcalamares.__dict__[ "job" ] = Job( moduledirpath, doc ) libcalamares.__dict__[ "job" ] = Job( moduledirpath, doc )
libcalamares.__dict__[ "global_storage" ] = libcalamares.GlobalStorage() libcalamares.__dict__[ "global_storage" ] = libcalamares.GlobalStorage()
# if a file for simulating global_storage contents is provided, load it
if len( sys.argv ) > 3:
doc = yaml.load( open( os.path.abspath( sys.argv[ 3 ] ), 'r' ) )
for key, value in doc.items():
libcalamares.global_storage.insert( key, value )
scriptpath = os.path.abspath( moduledirpath ) scriptpath = os.path.abspath( moduledirpath )
sys.path.append( scriptpath ) sys.path.append( scriptpath )
import main import main

Loading…
Cancel
Save