summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2012-11-12 17:32:20 +0100
committerMartin Sivak <msivak@redhat.com>2012-11-12 17:32:20 +0100
commit2789790d86e874e46d0ad2f4002d433fc24e7004 (patch)
tree7e781b32cda23d1a71ae92333a4cf429b725d20b
parenta633e4ab9ce969f49339fc4d2db998e7e8c93455 (diff)
downloadfirstboot2-2789790d86e874e46d0ad2f4002d433fc24e7004.tar.gz
firstboot2-2789790d86e874e46d0ad2f4002d433fc24e7004.tar.xz
firstboot2-2789790d86e874e46d0ad2f4002d433fc24e7004.zip
collect plugins and use the proper data structure to store their data
-rw-r--r--firstboot/gui/__main__.py71
-rw-r--r--firstboot/gui/hubs/firstboot.py1
2 files changed, 54 insertions, 18 deletions
diff --git a/firstboot/gui/__main__.py b/firstboot/gui/__main__.py
index 293c9ac..db27207 100644
--- a/firstboot/gui/__main__.py
+++ b/firstboot/gui/__main__.py
@@ -1,5 +1,57 @@
+import os
+
+addon_paths = ["addons"]
+
+def collect_plugins(addon_paths, ui = "gui"):
+ # collect all applicable addon paths from
+ # for p in addon_paths: <p>/<plugin id>/ks/*.(py|so)
+ # and register them under <plugin id> name
+
+ module_paths = {
+ "spokes": [],
+ "ks": [],
+ "categories": []
+ }
+
+ for path in addon_paths:
+ try:
+ files = os.listdir(path)
+ except OSError:
+ files = []
+
+ for addon_id in files:
+ addon_ks_path = os.path.join(path, addon_id, "ks")
+ if os.path.isdir(addon_ks_path):
+ module_paths["ks"].append(("anaconda.addon.%s.ks.%%s" % addon_id, addon_ks_path))
+
+ addon_spoke_path = os.path.join(path, addon_id, ui, "spokes")
+ if os.path.isdir(addon_spoke_path):
+ module_paths["spokes"].append(("anaconda.addon.%s.spokes.%%s" % addon_id, addon_spoke_path))
+
+ addon_category_path = os.path.join(path, addon_id, ui, "categories")
+ if os.path.isdir(addon_spoke_path):
+ module_paths["categories"].append(("anaconda.addon.%s.categories.%%s" % addon_id, addon_category_path))
+
+ return module_paths
+
+addon_module_paths = collect_plugins(addon_paths)
+print addon_module_paths
+
+# Too bad anaconda does not have modularized logging
+from pyanaconda import anaconda_log
+anaconda_log.init()
+
+# Prepare data object
+from pyanaconda import kickstart
+data = kickstart.AnacondaKSHandler(addon_module_paths["ks"])
+
+
+# Import gui specifics
import gui
+# Add to search paths
+gui.FirstbootGraphicalUserInterface.update_paths(addon_module_paths)
+
# We need this so we can tell GI to look for overrides objects
# also in anaconda source directories
import os
@@ -7,26 +59,9 @@ import gi.overrides
for p in os.environ.get("ANACONDA_WIDGETS_OVERRIDES", "").split(":"):
gi.overrides.__path__.insert(0, p)
-# Too bad anaconda does not have modularized logging
-from pyanaconda import anaconda_log
-anaconda_log.init()
-
-class O(object):
- pass
g = gui.FirstbootGraphicalUserInterface(None, None, None)
-
-class O(object):
- def __init__(self, d):
- self.__dict__ = d
-
-data = O({
- "rootpw": O({
- "lock": False,
- })
- })
-
g.setup(data)
-g.run()
+g.run()
diff --git a/firstboot/gui/hubs/firstboot.py b/firstboot/gui/hubs/firstboot.py
index 6a12029..762eab8 100644
--- a/firstboot/gui/hubs/firstboot.py
+++ b/firstboot/gui/hubs/firstboot.py
@@ -18,6 +18,7 @@ def collect_spokes(mask_paths):
spokes.extend(collect(mask, path,
lambda obj: hasattr(obj, "firstboot")))
+ print spokes
return spokes