summaryrefslogtreecommitdiffstats
path: root/pyanaconda/ui
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2013-01-03 15:16:09 +0100
committerMartin Sivak <msivak@redhat.com>2013-01-03 15:22:58 +0100
commit4d6c691a13343c9ddc22d9d97bb8653f81bd7be9 (patch)
tree8769c58edbcce192ae4984cb55f6976575fc7711 /pyanaconda/ui
parentde5138e074aa17e825078b8475982b3538152c10 (diff)
downloadanaconda-4d6c691a13343c9ddc22d9d97bb8653f81bd7be9.tar.gz
anaconda-4d6c691a13343c9ddc22d9d97bb8653f81bd7be9.tar.xz
anaconda-4d6c691a13343c9ddc22d9d97bb8653f81bd7be9.zip
Fix multiple copies of spokes appearing from update image
Diffstat (limited to 'pyanaconda/ui')
-rw-r--r--pyanaconda/ui/common.py8
-rw-r--r--pyanaconda/ui/gui/__init__.py11
-rw-r--r--pyanaconda/ui/tui/__init__.py8
3 files changed, 21 insertions, 6 deletions
diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
index a43a5d0cf..2bd783e50 100644
--- a/pyanaconda/ui/common.py
+++ b/pyanaconda/ui/common.py
@@ -496,8 +496,16 @@ def collect(module_pattern, path, pred):
imp.acquire_lock()
mod_info = imp.find_module(mod_name, [path])
module = sys.modules.get(module_pattern % mod_name)
+
+ # do not load module if any module with the same name
+ # is already imported
if not module:
module = imp.load_module(module_pattern % mod_name, *mod_info)
+
+ # do not collect classes when the module is already imported
+ # from different path than we are traversing
+ if mod_info[1] != module.__file__:
+ continue
imp.release_lock()
except ImportError:
continue
diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index 1ffc49048..d8febe98a 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -18,7 +18,7 @@
#
# Red Hat Author(s): Chris Lumens <clumens@redhat.com>
#
-import inspect, os, sys, time
+import inspect, os, sys, time, site
import meh.ui.gui
from gi.repository import Gdk
@@ -244,17 +244,20 @@ class GraphicalUserInterface(UserInterface):
basemask = "pyanaconda.ui.gui"
basepath = os.path.dirname(__file__)
updatepath = "/tmp/updates/pyanaconda/ui/gui"
+ sitepackages = [os.path.join(dir, "pyanaconda", "ui", "gui")
+ for dir in site.getsitepackages()]
+ pathlist = set([updatepath, basepath] + sitepackages)
paths = UserInterface.paths + {
"categories": [(basemask + ".categories.%s",
os.path.join(path, "categories"))
- for path in (updatepath, basepath)],
+ for path in pathlist],
"spokes": [(basemask + ".spokes.%s",
os.path.join(path, "spokes"))
- for path in (updatepath, basepath)],
+ for path in pathlist],
"hubs": [(basemask + ".hubs.%s",
os.path.join(path, "hubs"))
- for path in (updatepath, basepath)]
+ for path in pathlist]
}
def _list_hubs(self):
diff --git a/pyanaconda/ui/tui/__init__.py b/pyanaconda/ui/tui/__init__.py
index 1bf71e719..ba6d5b8ab 100644
--- a/pyanaconda/ui/tui/__init__.py
+++ b/pyanaconda/ui/tui/__init__.py
@@ -28,6 +28,7 @@ from hubs.progress import ProgressHub
from spokes import StandaloneSpoke
import os
+import site
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
@@ -132,14 +133,17 @@ class TextUserInterface(ui.UserInterface):
basemask = "pyanaconda.ui.tui"
basepath = os.path.dirname(__file__)
updatepath = "/tmp/updates/pyanaconda/ui/tui"
+ sitepackages = [os.path.join(dir, "pyanaconda", "ui", "tui")
+ for dir in site.getsitepackages()]
+ pathlist = set([updatepath, basepath] + sitepackages)
paths = ui.UserInterface.paths + {
"spokes": [(basemask + ".spokes.%s",
os.path.join(path, "spokes"))
- for path in (updatepath, basepath)],
+ for path in pathlist],
"hubs": [(basemask + ".hubs.%s",
os.path.join(path, "hubs"))
- for path in (updatepath, basepath)]
+ for path in pathlist]
}
def _list_hubs(self):