[blivet] Make progress report a stub on AttributeError as well as ImportError.

Anne Mulhern amulhern at redhat.com
Tue Nov 26 18:16:32 UTC 2013


That seems to be already there. How is this solution, instead:

===================================================================

[blivet] Move pyanaconda import into blivet.enable_installer_mode.

Most pyanaconda imports are allready set up this way. Now, so is
the import of progress_report in deviceaction.py.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/__init__.py     | 3 +++
 blivet/deviceaction.py | 5 +----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index d811b2c..84a6d29 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -121,6 +121,9 @@ def enable_installer_mode():

     flags.installer_mode = True

+    from pyanaconda.progress import progress_report
+    deviceaction.progress_report = progress_report
+
 def storageInitialize(storage, ksdata, protected):
     """ Perform installer-specific storage initialization. """
     from pyanaconda.flags import flags as anaconda_flags
diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
index 497934e..96a8af6 100644
--- a/blivet/deviceaction.py
+++ b/blivet/deviceaction.py
@@ -43,10 +43,7 @@ from contextlib import contextmanager
 def progress_report_stub(message):
     yield

-try:
-    from pyanaconda.progress import progress_report
-except ImportError:
-    progress_report = progress_report_stub
+progress_report = progress_report_stub

 # The values are just hints as to the ordering.
 # Eg: fsmod and devmod ordering depends on the mod (shrink -v- grow)
-- 
1.8.3.1


----- Original Message -----
From: "David Lehman" <dlehman at redhat.com>
To: "anaconda patch review" <anaconda-patches at lists.fedorahosted.org>
Sent: Tuesday, November 26, 2013 11:46:29 AM
Subject: Re: [blivet] Make progress report a stub on AttributeError as well	as ImportError.

On Tue, 2013-11-26 at 10:54 -0500, mulhern wrote:
> Import can also fail if the version of blivet that you are developing
> is too far out of sync with the version of anaconda on your machine.

A better solution would be to gather up all the imports from pyanaconda
into a function that only gets run when enabling installer mode, if
that's feasible. I guess this will do until we get something more robust
in place.

> 
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
>  blivet/deviceaction.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
> index 497934e..28d60df 100644
> --- a/blivet/deviceaction.py
> +++ b/blivet/deviceaction.py
> @@ -45,7 +45,7 @@ def progress_report_stub(message):
>  
>  try:
>      from pyanaconda.progress import progress_report
> -except ImportError:
> +except (ImportError, AttributeError):
>      progress_report = progress_report_stub
>  
>  # The values are just hints as to the ordering.


_______________________________________________
anaconda-patches mailing list
anaconda-patches at lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches


More information about the anaconda-patches mailing list