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@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
On 10/03/2013 05:41 AM, Vratislav Podzimek wrote:
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--
ImportError is still mentioned in the comment. Otherwise, ack.
On Thu, 2013-10-03 at 11:28 -0400, David Shea wrote:
On 10/03/2013 05:41 AM, Vratislav Podzimek wrote:
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--
ImportError is still mentioned in the comment. Otherwise, ack.
Good catch, thanks! Fixing locally.
anaconda-patches@lists.fedorahosted.org