# Setup logging
log = logging.getLogger("bricklayer")
+def positive_int(value):
+ """
+ A helper function to accept only positive integers on the command line
+ """
+ # Convert to integer
+ value = int(value)
+
+ # Raise an error if the value is negative
+ if value < 0:
+ raise argparse.ArgumentTypeError(_("Must be a positive integer or zero"))
+
+ # Return the value
+ return value
+
class Cli(object):
"""
This class is called from the command line interface and parses any
help=_("Enable debugging mode"))
parser.add_argument("--unattended", action="store_true",
help=_("Enable unattended mode"))
+ parser.add_argument("--unattended-timeout", nargs="?", type=positive_int,
+ help=_("Seconds to wait before launching the unattended installation"))
parser.add_argument("--disk", nargs="*", dest="disks", default=[],
help=_("A disk image file or device which will be used"))
parser.add_argument("--serial", action="store_true",
Bricklayer's base class
"""
def __init__(self, arch, pakfire_config=None, first_install=False, debug=False,
- unattended=False, disks=[], serial=False, ignore_kernel_cmdline=False):
+ unattended=False, unattended_timeout=10, disks=[], serial=False,
+ ignore_kernel_cmdline=False):
self.arch = arch
self.first_install = first_install
self.debug = debug
self.unattended = unattended
+ self.unattended_timeout = unattended_timeout
# Enable debug logging
if debug:
class UnattendedWarning(UnattendedStep):
def run(self):
- timeout = 10
disks = self.bricklayer.disks.selected
message = _(
"The unattended installation will start in %(timeout)s seconds using %(disks)s",
) % {
- "timeout" : timeout,
+ "timeout" : self.bricklayer.unattended_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):
+ buttons=[_("Cancel Unattended Installation")], timeout=self.bricklayer.unattended_timeout):
raise InstallAbortedError