]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
Add steps and a simple proof-of-concept welcome step
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 May 2021 16:03:44 +0000 (16:03 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 May 2021 16:03:44 +0000 (16:03 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/python/__init__.py
src/python/step.py [new file with mode: 0644]

index 0623158766a7916a299581a4c7d961a700e36fa1..9a395886226fb30317f600398c0a6fc1c5404e1d 100644 (file)
@@ -46,7 +46,8 @@ dist_bin_SCRIPTS = \
 dist_pkgpython_PYTHON = \
        src/python/__init__.py \
        src/python/i18n.py \
-       src/python/logger.py
+       src/python/logger.py \
+       src/python/step.py
 
 pkgpython_tuidir = $(pkgpythondir)/tui
 
index 5667f546968d2205341aa69501493a81af5c4137..80e02182dc0af68ed9438e824bb60b135d996657 100644 (file)
@@ -21,6 +21,7 @@
 import logging
 
 from . import logger
+from . import step
 from . import tui
 
 # Setup logging
@@ -47,6 +48,27 @@ class Bricklayer(object):
                else:
                        log.info("Bricklayer initialized")
 
+       # An ordered list of all available steps
+       steps = (
+               step.Welcome,
+       )
+
        def __call__(self):
                with self.tui:
-                       pass
+                       # Walk through all steps
+                       for step in self.steps:
+                               self._run_step(step)
+
+       def _run_step(self, stepcls):
+               """
+                       Runs a single step
+               """
+               # Initialize the step
+               step = stepcls(self)
+
+               # Skip this step if it isn't enabled
+               if not step.enabled:
+                       return
+
+               # Run it
+               return step.run(self.tui)
diff --git a/src/python/step.py b/src/python/step.py
new file mode 100644 (file)
index 0000000..49aefc6
--- /dev/null
@@ -0,0 +1,74 @@
+###############################################################################
+#                                                                             #
+# Bricklayer - An Installer for IPFire                                        #
+# Copyright (C) 2021 IPFire Development Team                                  #
+#                                                                             #
+# This program is free software; you can redistribute it and/or               #
+# modify it under the terms of the GNU General Public License                 #
+# as published by the Free Software Foundation; either version 2              #
+# of the License, or (at your option) any later version.                      #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+import logging
+
+import snack
+
+from .i18n import _
+
+# Setup logging
+log = logging.getLogger("bricklayer.step")
+
+class Step(object):
+       """
+               Steps are the heart of this installer. They perform actions and are
+               being executed one after the other.
+       """
+       # This enables or disables this step
+       enabled = True
+
+       def __init__(self, bricklayer):
+               self.bricklayer = bricklayer
+
+               log.debug("Initializing step %s" % self.__class__.__name__)
+
+               # Call the custom initialization
+               self.initialize()
+
+       def initialize(self):
+               """
+                       Custom initialization action to be overlayed
+               """
+               pass
+
+       def run(self, tui):
+               """
+                       Run this step - to be overlayed
+               """
+               pass
+
+
+class Welcome(Step):
+       """
+               Shows a very warm welcome message to the user
+       """
+       @property
+       def enabled(self):
+               # Disable in unattended mode
+               return not self.bricklayer.unattended
+
+       def run(self, tui):
+               tui.message(
+                       title=_("Welcome"),
+                       text=_("Welcome to the %s installation program.\n\n"
+                               "Selecting Cancel on any of the following screens will reboot the computer."),
+                       buttons=(_("Start Installation"), _("Cancel"))
+               )