[PATCH 4/4] Handle automated installs

Vratislav Podzimek vpodzime at redhat.com
Thu Sep 20 08:25:50 UTC 2012


On Wed, 2012-09-19 at 16:54 -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 | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/pyanaconda/ui/tui/hubs/summary.py b/pyanaconda/ui/tui/hubs/summary.py
> index 8c2f4cc..7a74eca 100644
> --- a/pyanaconda/ui/tui/hubs/summary.py
> +++ b/pyanaconda/ui/tui/hubs/summary.py
> @@ -17,9 +17,13 @@
>  # Red Hat, Inc.
>  #
>  # Red Hat Author(s): Martin Sivak <msivak at redhat.com>
> +#                    Jesse Keating <jkeating at redhat.com>
>  #
>  
>  from pyanaconda.ui.tui.hubs import TUIHub
> +from pyanaconda.flags import flags
> +import sys
> +import time
>  
>  import gettext
>  _ = lambda x: gettext.ldgettext("anaconda", x)
> @@ -27,3 +31,29 @@ _ = 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:
> +            sys.stdout.write(_("Starting automated install"))
> +            sys.stdout.flush()
> +            spokes = self._keys.values()
> +            while True:
> +                if all(spoke.ready for spoke in spokes):
> +                    print('')
> +                    break
> +                sys.stdout.write('.')
> +                sys.stdout.flush()
> +                time.sleep(1)
I believe there's no reason for a while-True-cycle that starts with "if
something, then break". You can rewrite it as:

while not all(spoke.ready for spoke in spokes):
    sys.stdout.write('.')
    sys.stdout.flush()
    time.sleep(1)

print

-- 
Vratislav Podzimek

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



More information about the anaconda-patches mailing list