Re: [master] dispatcher: allow requesting a step without insisting.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ack.

I like the function name.

On Wed, 2011-07-27 at 16:08 +0200, Ales Kozumplik wrote:
> Introduces Dispatcher.request_steps_gently() which requests steps if they
> are not skipped already (i.e. "Unless there is a compelling reason, like a
> kickstart command, not to run this step, it must be run.").
> 
> Resolves: rhbz#723798
> ---
>  pyanaconda/dispatch.py                 |   10 ++++++++++
>  pyanaconda/iw/autopart_type.py         |    3 ++-
>  pyanaconda/storage/partitioning.py     |    6 +-----
>  tests/pyanaconda_test/dispatch_test.py |   12 ++++++++++++
>  4 files changed, 25 insertions(+), 6 deletions(-)
> 
> diff --git a/pyanaconda/dispatch.py b/pyanaconda/dispatch.py
> index 3d4b9b2..820a92b 100644
> --- a/pyanaconda/dispatch.py
> +++ b/pyanaconda/dispatch.py
> @@ -290,6 +290,16 @@ class Dispatcher(object):
>      def request_steps(self, *steps):
>          changes = map(lambda s: self.steps[s].request(self._current_step()), steps)
>  
> +    def request_steps_gently(self, *steps):
> +        """ Requests steps and won't raise an error if it is not possible for
> +            some of them.
> +        """
> +        for step in steps:
> +            try:
> +                self.request_steps(step)
> +            except errors.DispatchError as e:
> +                log.debug("dispatch: %s" % e)
> +
>      def run(self):
>          self.anaconda.intf.run(self.anaconda)
>          log.info("dispatch: finished.")
> diff --git a/pyanaconda/iw/autopart_type.py b/pyanaconda/iw/autopart_type.py
> index d69b5f9..999c281 100644
> --- a/pyanaconda/iw/autopart_type.py
> +++ b/pyanaconda/iw/autopart_type.py
> @@ -202,7 +202,8 @@ class PartitionTypeWindow(InstallWindow):
>  
>              if self.reviewButton.get_active():
>                  self.dispatch.request_steps("partition")
> -                self.dispatch.request_steps("bootloader")
> +                # with kickstart bootloader is already scheduled to be skipped:
> +                self.dispatch.request_steps_gently("bootloader")
>              else:
>                  self.dispatch.skip_steps("partition")
>                  self.dispatch.skip_steps("bootloader")
> diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
> index a594697..ffb4ef4 100644
> --- a/pyanaconda/storage/partitioning.py
> +++ b/pyanaconda/storage/partitioning.py
> @@ -29,7 +29,6 @@ from pykickstart.constants import *
>  
>  from pyanaconda.constants import *
>  
> -from pyanaconda.errors import DispatchError
>  from errors import *
>  from deviceaction import *
>  from devices import PartitionDevice, LUKSDevice, devicePathToName
> @@ -301,10 +300,7 @@ def doAutoPartition(anaconda):
>          if anaconda.ksdata:
>              extra = _("\n\nPress 'OK' to exit the installer.")
>          else:
> -            try:
> -                anaconda.dispatch.request_steps("partition")
> -            except DispatchError:
> -                pass
> +            anaconda.dispatch.request_steps_gently("partition")
>          anaconda.intf.messageWindow(_("Error Partitioning"),
>                 _("Could not allocate requested partitions: \n\n"
>                   "%(msg)s.%(extra)s") % {'msg': msg, 'extra': extra},
> diff --git a/tests/pyanaconda_test/dispatch_test.py b/tests/pyanaconda_test/dispatch_test.py
> index c84427a..57de692 100644
> --- a/tests/pyanaconda_test/dispatch_test.py
> +++ b/tests/pyanaconda_test/dispatch_test.py
> @@ -171,6 +171,18 @@ class DispatchTest(mock.TestCase):
>          self.assertFalse(d.step_enabled("complete"))
>          self.assertTrue(d.step_enabled("filtertype"))
>  
> +    def request_steps_gently_test(self):
> +        from pyanaconda.errors import DispatchError
> +        from pyanaconda.dispatch import Step
> +        d = self._getDispatcher()
> +        d.schedule_steps("betanag", "complete")
> +        d.skip_steps("betanag")
> +        self.assertRaises(DispatchError, d.request_steps, "betanag")
> +        d.request_steps_gently("betanag")
> +        d.request_steps_gently("complete")
> +        self.assertEqual(d.steps["betanag"].sched, Step.SCHED_SKIPPED)
> +        self.assertEqual(d.steps["complete"].sched, Step.SCHED_REQUESTED)
> +
>      def track_scheduling_test(self):
>          from pyanaconda.dispatch import Step
>          d = self._getDispatcher()
> -- 
> 1.7.6
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

-- 
Martin Gracik <mgracik@xxxxxxxxxx>

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux