update the module loading paths for the new locations
authorBrian Dolbec <dolsen@gentoo.org>
Fri, 11 Jan 2013 03:34:53 +0000 (19:34 -0800)
committerBrian Dolbec <dolsen@gentoo.org>
Thu, 28 Feb 2013 01:38:11 +0000 (17:38 -0800)
catalyst/main.py
catalyst/modules/generic_stage_target.py

index 763107b0451d475ac895f794159c0188e008794d..b4390b2e617aef7912b61edd433cb8044428e195 100644 (file)
@@ -119,6 +119,9 @@ def parse_config(myconfig):
                        print "Setting",x,"to default value \""+confdefaults[x]+"\""
                        conf_values[x]=confdefaults[x]
 
+       # add our python base directory to use for loading target arch's
+       conf_values["PythonDir"] = __selfpath__
+
        # parse out the rest of the options from the config file
        if "autoresume" in string.split(conf_values["options"]):
                print "Autoresuming support enabled."
@@ -197,32 +200,32 @@ def import_modules():
        targetmap={}
 
        try:
+               module_dir = __selfpath__ + "/modules/"
                for x in required_build_targets:
                        try:
-                               fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
-                               module=imp.load_module(x,fh,"modules/"+x+".py",
-                                       (".py","r",imp.PY_SOURCE))
+                               fh=open(module_dir + x + ".py")
+                               module=imp.load_module(x, fh,"modules/" + x + ".py",
+                                       (".py", "r", imp.PY_SOURCE))
                                fh.close()
 
                        except IOError:
-                               raise CatalystError,"Can't find "+x+".py plugin in "+\
-                                       conf_values["sharedir"]+"/modules/"
-
+                               raise CatalystError, "Can't find " + x + ".py plugin in " + \
+                                       module_dir
                for x in valid_build_targets:
                        try:
-                               fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
-                               module=imp.load_module(x,fh,"modules/"+x+".py",
-                                       (".py","r",imp.PY_SOURCE))
+                               fh=open(module_dir + x + ".py")
+                               module=imp.load_module(x, fh, "modules/" + x + ".py",
+                                       (".py", "r", imp.PY_SOURCE))
                                module.register(targetmap)
                                fh.close()
 
                        except IOError:
-                               raise CatalystError,"Can't find "+x+".py plugin in "+\
-                                       conf_values["sharedir"]+"/modules/"
+                               raise CatalystError,"Can't find " + x + ".py plugin in " + \
+                                       module_dir
 
        except ImportError:
                print "!!! catalyst: Python modules not found in "+\
-                       conf_values["sharedir"]+"/modules; exiting."
+                       module_dir + "; exiting."
                sys.exit(1)
 
        return targetmap
index 927b4c3334df4aa8922740136ecdcd395cc11412..f77527d4a325f188a7bf6f6e523f7b930d0bb194 100644 (file)
@@ -48,16 +48,16 @@ class generic_stage_target(generic_target):
                self.archmap = {}
                self.subarchmap = {}
                machinemap = {}
-               for x in [x[:-3] for x in os.listdir(self.settings["sharedir"]+\
-                       "/arch/") if x.endswith(".py")]:
+               arch_dir = self.settings["PythonDir"] + "/arch/"
+               for x in [x[:-3] for x in os.listdir(arch_dir) if x.endswith(".py")]:
                        try:
-                               fh=open(self.settings["sharedir"]+"/arch/"+x+".py")
+                               fh=open(arch_dir + x + ".py")
                                """
                                This next line loads the plugin as a module and assigns it to
                                archmap[x]
                                """
-                               self.archmap[x]=imp.load_module(x,fh,"arch/"+x+\
-                                       ".py",(".py","r",imp.PY_SOURCE))
+                               self.archmap[x]=imp.load_module(x,fh,"../arch/" + x + ".py",
+                                       (".py", "r", imp.PY_SOURCE))
                                """
                                This next line registers all the subarches supported in the
                                plugin
@@ -75,8 +75,7 @@ class generic_stage_target(generic_target):
                                the dir should load just fine. If it doesn't, it's probably a
                                syntax error in the module
                                """
-                               msg("Can't find/load "+x+".py plugin in "+\
-                                       self.settings["sharedir"]+"/arch/")
+                               msg("Can't find/load " + x + ".py plugin in " + arch_dir)
 
                if "chost" in self.settings:
                        hostmachine = self.settings["chost"].split("-")[0]