From 5c8fa759b03c606fa961bbfac952581c896799e5 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 6 Aug 2014 12:36:10 +0200 Subject: [PATCH] Update testmodule.py for new config structure. --- src/modules/testmodule.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/modules/testmodule.py b/src/modules/testmodule.py index 1e52a8e0e..ad3752e89 100755 --- a/src/modules/testmodule.py +++ b/src/modules/testmodule.py @@ -34,11 +34,11 @@ except ImportError: class Job: - def __init__(self, working_path, doc): + def __init__(self, working_path, doc, cfg_doc): self.module_name = doc["name"] self.pretty_name = "Testing job " + doc["name"] self.working_path = working_path - self.configuration = doc["configuration"] + self.configuration = cfg_doc def setprogress(self, progress): print("Job set progress to {}%.".format(progress * 100)) @@ -47,9 +47,11 @@ class Job: def main(): parser = argparse.ArgumentParser() parser.add_argument("moduledir", - help="Dir containing the Python module") + help="Dir containing the Python module.") parser.add_argument("globalstorage_yaml", nargs="?", - help="A yaml file to initialize GlobalStorage") + help="A yaml file to initialize GlobalStorage.") + parser.add_argument("configuration_yaml", nargs="?", + help="A yaml file to initialize the configuration dict.") args = parser.parse_args() print("Testing module in: " + args.moduledir) @@ -62,16 +64,21 @@ def main(): print("Only Python jobs can be tested.") return 1 - libcalamares.job = Job(args.moduledir, doc) - libcalamares.globalstorage = libcalamares.GlobalStorage() - # 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) + gs_doc = yaml.load(f) for key, value in doc.items(): libcalamares.globalstorage.insert(key, value) + cfg_doc = dict() + if args.configuration_yaml: + with open(args.configuration_yaml) as f: + cfg_doc = yaml.load(f) + + libcalamares.job = Job(args.moduledir, doc, cfg_doc) + libcalamares.globalstorage = libcalamares.GlobalStorage() + scriptpath = os.path.abspath(args.moduledir) sys.path.append(scriptpath) import main