]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
steps: Move TUI into Step class
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 May 2021 19:47:14 +0000 (19:47 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 May 2021 19:47:14 +0000 (19:47 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/__init__.py
src/python/bootloaders.py
src/python/disk.py
src/python/packages.py
src/python/step.py
src/python/timezones.py

index d6c1846117af35798c1f1164eb2bf1958aeac50b..e1b1c483d671fadf32cb4eab3898bbaf70e056cb 100644 (file)
@@ -180,14 +180,14 @@ class Bricklayer(object):
                        Runs a single step
                """
                # Initialize the step
-               step = stepcls(self)
+               step = stepcls(self, tui=self.tui)
 
                # Skip this step if it isn't enabled
                if not step.enabled:
                        return
 
                # Run it
-               return step.run(self.tui)
+               return step.run()
 
        def _read_os_release(self):
                """
index d8bbbfe634c4e6bb4aa55f196cf6da4729ffd904..e16a68473ddac65c6c62f39e943808e3ca4370e6 100644 (file)
@@ -130,18 +130,18 @@ class InstallBootloader(step.Step):
        """
                Installs the bootloader
        """
-       def run(self, tui):
+       def run(self):
                # Find all packages that need to be installed
                packages = []
                for bootloader in self.bricklayer.bootloaders:
                        packages += bootloader.packages
 
                # Install them
-               self.install_packages(tui, packages)
+               self.install_packages(packages)
 
                # Install all bootloaders
                for bootloader in self.bricklayer.bootloaders:
-                       with tui.progress(
+                       with self.tui.progress(
                                _("Installing Bootloader"),
                                _("Installing bootloader \"%s\"...") % _(bootloader.name),
                        ):
index c4196f3370af33bf160c70bbe5750f30f6289abe..5827c0f61ffc37caabca6eaeed2e496b3f6deed7 100644 (file)
@@ -416,13 +416,13 @@ class SelectDisk(step.InteractiveStep):
                # Scan for disks
                self.disks.scan()
 
-       def run(self, tui):
+       def run(self):
                # Create a dictionary with all disks
                disks = { disk : "%s" % disk for disk in self.disks.supported }
 
                # Show an error if no suitable disks were found
                if not disks:
-                       tui.error(
+                       self.tui.error(
                                _("No Disks Found"),
                                _("No supported disks were found")
                        )
@@ -434,7 +434,7 @@ class SelectDisk(step.InteractiveStep):
 
                while True:
                        # Select disks
-                       selection = tui.select(
+                       selection = self.tui.select(
                                _("Disk Selection"),
                                _("Please select all disks for installation"),
                                disks, default=selection, multi=True, width=60,
@@ -442,7 +442,7 @@ class SelectDisk(step.InteractiveStep):
 
                        # Is at least one disk selected?
                        if not selection:
-                               tui.error(
+                               self.tui.error(
                                        _("No Disk Selected"),
                                        _("Please select a disk to continue the installation"),
                                        buttons=[_("Back")],
@@ -460,7 +460,7 @@ class CalculatePartitionLayout(step.Step):
        """
                Calculates the partition layout
        """
-       def run(self, tui):
+       def run(self):
                # This probably will be fast enough that we do not need to show anything
 
                # Perform the job
@@ -471,10 +471,10 @@ class CreatePartitionLayout(step.Step):
        """
                Creates the desired partition layout on disk
        """
-       def run(self, tui):
+       def run(self):
                log.debug("Creating partitions")
 
-               with tui.progress(
+               with self.tui.progress(
                        _("Creating Partition Layout"),
                        _("Creating partition layout..."),
                ):
@@ -486,10 +486,10 @@ class CreateFilesystems(step.Step):
        """
                Formats all newly created partitions
        """
-       def run(self, tui):
+       def run(self):
                for disk in self.bricklayer.disks.selected:
                        for partition in disk.partitions:
-                               with tui.progress(
+                               with self.tui.progress(
                                        _("Creating Filesystems"),
                                        _("Formatting partition \"%s\"...") % (partition.name or partition.path)
                                ):
@@ -500,8 +500,8 @@ class MountFilesystems(step.Step):
        """
                Mount all filesystems
        """
-       def run(self, tui):
-               with tui.progress(
+       def run(self):
+               with self.tui.progress(
                        _("Mounting Filesystems"),
                        _("Mounting filesystems..."),
                ):
@@ -512,8 +512,8 @@ class UmountFilesystems(step.Step):
        """
                Umount all filesystems
        """
-       def run(self, tui):
-               with tui.progress(
+       def run(self):
+               with self.tui.progress(
                        _("Umounting Filesystems"),
                        _("Umounting filesystems..."),
                ):
index b0f6beb64f90dea109a35b3149a782ea6ca2ac98..46a43312d218ed2784dc0a83b400dc147b919f2a 100644 (file)
@@ -21,8 +21,8 @@
 from . import step
 
 class InstallPackages(step.Step):
-       def run(self, tui):
+       def run(self):
                # Get list of all packages to be installed
                packages = self.bricklayer.settings.get("packages", [])
 
-               self.install_packages(tui, packages)
+               self.install_packages(packages)
index 91d0a4373c1ec711204f324441708069fd701dfc..c00c94a5e39cb55c63a6ed8f117f127c2130d95f 100644 (file)
@@ -39,8 +39,9 @@ class Step(object):
        # This enables or disables this step
        enabled = True
 
-       def __init__(self, bricklayer):
+       def __init__(self, bricklayer, tui):
                self.bricklayer = bricklayer
+               self.tui = tui
 
                log.debug("Initializing step %s" % self.__class__.__name__)
 
@@ -53,19 +54,19 @@ class Step(object):
                """
                pass
 
-       def run(self, tui):
+       def run(self):
                """
                        Run this step - to be overlayed
                """
                pass
 
-       def install_packages(self, tui, packages):
+       def install_packages(self, packages):
                # Nothing to do if there are no packages
                if not packages:
                        return
 
                # Set up Pakfire
-               with tui.progress(
+               with self.tui.progress(
                        _("Setting Up Pakfire"),
                        _("Pakfire is being set up..."),
                ):
@@ -73,7 +74,7 @@ class Step(object):
 
                with p as p:
                        # Resolve package dependencies
-                       with tui.progress(
+                       with self.tui.progress(
                                _("Resolving Dependencies"),
                                _("Resolving package dependencies..."),
                        ):
@@ -95,7 +96,7 @@ class Step(object):
 
                                                text.append("\n".join(lines))
 
-                                       tui.error(
+                                       self.tui.error(
                                                _("Dependency Problem"),
                                                _(
                                                        "A problem has occured during resolving package dependencies:\n\n%s",
@@ -109,7 +110,7 @@ class Step(object):
                        log.info("%s" % transaction.dump())
 
                        # Run the transaction
-                       with tui.progress(
+                       with self.tui.progress(
                                _("Installing Packages"),
                                _("Installing packages..."),
                        ):
@@ -130,12 +131,12 @@ class Welcome(InteractiveStep):
        """
                Shows a very warm welcome message to the user
        """
-       def run(self, tui):
+       def run(self):
                name = self.bricklayer.os.get("NAME")
                current_language = self.bricklayer.settings.get("language")
 
                # Let the user select
-               lang = tui.select(
+               lang = self.tui.select(
                        _("Willkommen, Bienvenue, Welcome!"),
                        _("Select the language you wish to use for the installation"),
                        i18n.supported_languages, default=current_language,
@@ -155,8 +156,8 @@ class Congratulations(InteractiveStep):
        """
                Shows a message that the installation is complete
        """
-       def run(self, tui):
-               tui.message(
+       def run(self):
+               self.tui.message(
                        _("Congratulations"),
                        _(
                                "The installation has been completed successfully."
@@ -175,10 +176,10 @@ class UnattendedWarning(Step):
                # Only enabled in unattended mode
                return self.bricklayer.unattended
 
-       def run(self, tui):
+       def run(self):
                seconds = 10
 
-               p = tui.progress(
+               p = self.tui.progress(
                        _("Unattended Installation"),
                        _("Unattended installation is starting in %s seconds") % seconds,
                        max_value=seconds * 10,
@@ -192,8 +193,8 @@ class UnattendedWarning(Step):
 
 
 class RootPassword(InteractiveStep):
-       def run(self, tui):
-               password = tui.passwd(
+       def run(self):
+               password = self.tui.passwd(
                        _("Root Password"),
                        _("Please enter the password for the 'root' user"),
                )
index 661440da848b04640f8f8501dff2c5544c8bb44a..adb15bfa8c99a4182ec36d8201afae626dd10dd1 100644 (file)
@@ -28,7 +28,7 @@ from .i18n import _
 log = logging.getLogger("bricklayer.timezones")
 
 class SelectTimezone(step.InteractiveStep):
-       def run(self, tui):
+       def run(self):
                # Get a list of all available timezones
                timezones = {
                        tz : tz for tz in sorted(pytz.all_timezones)
@@ -37,7 +37,7 @@ class SelectTimezone(step.InteractiveStep):
                # Which timezone is currently selected?
                timezone = self.bricklayer.settings.get("timezone", "UTC")
 
-               timezone = tui.select(
+               timezone = self.tui.select(
                        _("Timezone"),
                        _("Please select the timezone:"),
                        timezones, default=timezone,