[PATCH 3/3] Handle automated installs

Vratislav Podzimek vpodzime at redhat.com
Wed Sep 19 08:12:35 UTC 2012


On Tue, 2012-09-18 at 13:08 -0700, Jesse Keating wrote:
> This follows the same design as GUI.  If the install is automated, and
> all the spokes are complete, proceed into the installation phase.
> However if there are incomplete spokes, let the user finish those
> spokes.  As soon as all spokes are complete jump straight to the install
> phase.
> 
> Note that any new spoke that has a background process that could make it
> not be "ready" immediately is going to have to be accounted for here,
> which is ugly.  Perhaps a object attribute that is a list of potential
> threads to join would work?
> ---
>  pyanaconda/ui/tui/hubs/summary.py | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/pyanaconda/ui/tui/hubs/summary.py b/pyanaconda/ui/tui/hubs/summary.py
> index 8c2f4cc..47cc73d 100644
> --- a/pyanaconda/ui/tui/hubs/summary.py
> +++ b/pyanaconda/ui/tui/hubs/summary.py
> @@ -20,6 +20,7 @@
>  #
>  
>  from pyanaconda.ui.tui.hubs import TUIHub
> +from pyanaconda.flags import flags
>  
>  import gettext
>  _ = lambda x: gettext.ldgettext("anaconda", x)
> @@ -27,3 +28,33 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
>  class SummaryHub(TUIHub):
>      title = _("Install hub")
>      categories = ["source", "localization", "destination", "password"]
> +
> +    def __init__(self, app, data, storage, payload, instclass):
> +        TUIHub.__init__(self, app, data, storage, payload, instclass)
> +        if flags.automatedInstall:
> +            print(_("Starting automated install"))
> +            # Join the initialization thread to block on it
> +            from pyanaconda.threads import threadMgr
> +
> +            # This assumes that the storage thread is the only
> +            # one that can be "unready".  This puts knowledge here
> +            # that really shouldn't be here.
> +            initThread = threadMgr.get("AnaStorageWatcher")
> +            if initThread:
> +                print(_("Probing storage..."))
> +                initThread.join()
> +
> +            for spoke in self._keys.values():
> +                if spoke.ready:
> +                    spoke.execute()
> +
> +    # override the prompt so that we can skip user input on kickstarts
> +    # where all the data is in hand.  If not in hand, do the actual prompt.
> +    def prompt(self, args=None):
> +        if flags.automatedInstall:
> +            for spoke in self._keys.values():
> +                if not spoke.completed:
> +                    return TUIHub.prompt(self, args)
> +            self.close()
> +            return None
The for could probably be replaced with:

if all(spoke.completed for spoke in self._keys.itervalues()):
     self.close()
     return None
else:
     return TUIHub.prompt(self, args)

which is as efficient as the original code and, e.g. for me, better
readable.

> +        return TUIHub.prompt(self, args)
> \ No newline at end of file
^^^this should probably be fixed before pushing.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list