[master][PATCH] Don't try to collect removed modules
Vratislav Podzimek
vpodzime at redhat.com
Thu Oct 3 09:41:24 UTC 2013
If some module is removed, the makeupdates scripts replaces it with a stub
raising an error to crash when testing. However, methods collecting spokes and
hubs go over such modules without explicitly referring them in the code (what
would be a bug). We should ignore such errors and just ignore those modules.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/errors.py | 3 +++
pyanaconda/ui/common.py | 5 +++++
scripts/makeupdates | 3 ++-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/errors.py b/pyanaconda/errors.py
index fc861f9..cea7141 100644
--- a/pyanaconda/errors.py
+++ b/pyanaconda/errors.py
@@ -41,6 +41,9 @@ class MediaUnmountError(Exception):
class ScriptError(Exception):
pass
+class RemovedModuleError(ImportError):
+ pass
+
# These constants are returned by the callback in the ErrorHandler class.
# Each represents a different kind of action the caller can take:
#
diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
index 91d878f..1e6e2e7 100644
--- a/pyanaconda/ui/common.py
+++ b/pyanaconda/ui/common.py
@@ -28,6 +28,7 @@ import sys
import types
from pyanaconda.constants import ANACONDA_ENVIRON, FIRSTBOOT_ENVIRON
+from pyanaconda.errors import RemovedModuleError
from pykickstart.constants import FIRSTBOOT_RECONFIG
import logging
@@ -598,6 +599,10 @@ def collect(module_pattern, path, pred):
if not module_flags[0].startswith(".py") and loaded_ext.startswith(".py"):
continue
+ except RemovedModuleError:
+ # collected some removed module
+ continue
+
except ImportError as imperr:
if "pyanaconda" in module_path:
# failure when importing our own module:
diff --git a/scripts/makeupdates b/scripts/makeupdates
index f185a88..8bee657 100755
--- a/scripts/makeupdates
+++ b/scripts/makeupdates
@@ -224,7 +224,8 @@ def copyUpdatedFiles(tag, updates, cwd):
# deleted python module, write out a stub raising ImportError
file_path = os.path.join(tmpupdates, gitfile)
with open(file_path, "w") as fobj:
- fobj.write('raise ImportError("This module no longer exists!")')
+ fobj.write('from pyanaconda.errors import RemovedModuleError\n')
+ fobj.write('raise RemovedModuleError("This module no longer exists!")\n')
continue
--
1.8.3.1
More information about the anaconda-patches
mailing list