return gettext.dngettext("bricklayer", singular, plural, n)
return gettext.dgettext("bricklayer", singular)
+
+def list(objects):
+ length = len(objects)
+
+ if length == 0:
+ return ""
+ elif length == 1:
+ return objects[0]
+ else:
+ return _("%(commas)s, and %(last)s") % {
+ "commas" : ",".join(objects[:-1]),
+ "last" : objects[-1],
+ }
import snack
from . import i18n
+from .errors import *
from .i18n import _
# Setup logging
)
-class UnattendedWarning(Step):
- @property
- def enabled(self):
- # Only enabled in unattended mode
- return self.bricklayer.unattended
-
+class UnattendedWarning(UnattendedStep):
def run(self):
- seconds = 10
-
- p = self.tui.progress(
- _("Unattended Installation"),
- _("Unattended installation is starting in %s seconds") % seconds,
- max_value=seconds * 10,
- )
-
- with p as w:
- for i in range(seconds * 10):
- time.sleep(0.1)
-
- w.progress(i + 1)
+ timeout = 10
+ disks = self.bricklayer.disks.selected
+
+ message = _(
+ "The unattended installation will start in %(timeout)s seconds using %(disks)s",
+ "The unattended installation will start in %(timeout)s seconds using %(disks)s",
+ len(disks),
+ ) % {
+ "timeout" : timeout,
+ "disks" : i18n.list(disks),
+ }
+
+ # Show message to the user and allow them to cancel
+ if self.tui.message(_("Unattended Installation"), message,
+ buttons=[_("Cancel Unattended Installation")], timeout=timeout):
+ raise InstallAbortedError
class RootPassword(InteractiveStep):
self.screen.pushHelpLine(helpline)
- def message(self, title, text, buttons=None, height=None, width=40, help=None):
+ def message(self, title, text, buttons=None, height=None, width=40,
+ help=None, timeout=None):
"""
Shows a message to the user
"""
buttons = (_("OK"), _("Cancel"))
window = ButtonsWindow(self, title=title, text=text,
- buttons=buttons, height=height, width=width, help=help)
+ buttons=buttons, height=height, width=width, help=help, timeout=timeout)
return window.run()
class ButtonsWindow(Window):
- def __init__(self, tui, title, text, buttons=None, height=None, width=None, help=None):
+ def __init__(self, tui, title, text, buttons=None, height=None, width=None,
+ help=None, timeout=None):
Window.__init__(self, tui, title, text, height=height, width=width, help=help)
+ self.timeout = timeout
# Configure some default buttons
if buttons is None:
# Create the button bar
grid.add(self.buttons, 0, 1, growx=True)
+ # Set timeout
+ if self.timeout:
+ grid.setTimer(self.timeout * 1000)
+
return grid
def run(self):