From b5245b31fec9c19a16a8b00233afb1cfee1499fa Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 8 Apr 2021 21:14:19 +0200 Subject: I simplified the countdown, by moving it into it's own function instead of wrapped inside guided.. This can now be used by others for a simple countdown. I also re-worked the minimal.py example to work with the new internal partitioning logic API as well as support some flags from archinstall.arguments to minimize user input requirements to just one single question. This one question will most likely go away too, but stays for simplicity right now. --- examples/guided.py | 50 ++------------------------------------------------ 1 file changed, 2 insertions(+), 48 deletions(-) (limited to 'examples/guided.py') diff --git a/examples/guided.py b/examples/guided.py index a28aa50e..6feebd00 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,30 +1,8 @@ -import getpass, time, json, sys, signal, os +import getpass, time, json, os import archinstall from archinstall.lib.hardware import hasUEFI from archinstall.lib.profiles import Profile -""" -This signal-handler chain (and global variable) -is used to trigger the "Are you sure you want to abort?" question further down. -It might look a bit odd, but have a look at the line: "if SIG_TRIGGER:" -""" -SIG_TRIGGER = False -def kill_handler(sig, frame): - print() - exit(0) - -def sig_handler(sig, frame): - global SIG_TRIGGER - SIG_TRIGGER = True - signal.signal(signal.SIGINT, kill_handler) - -original_sigint_handler = signal.getsignal(signal.SIGINT) -signal.signal(signal.SIGINT, sig_handler) - -if archinstall.arguments.get('help'): - print("See `man archinstall` for help.") - exit(0) - def ask_user_questions(): """ First, we'll ask the user for a bunch of user input. @@ -206,8 +184,6 @@ def ask_user_questions(): def perform_installation_steps(): - global SIG_TRIGGER - print() print('This is your chosen configuration:') archinstall.log("-- Guided template chosen (with below config) --", level=archinstall.LOG_LEVELS.Debug) @@ -222,29 +198,7 @@ def perform_installation_steps(): """ print(f" ! Formatting {archinstall.arguments['harddrive']} in ", end='') - - for i in range(5, 0, -1): - print(f"{i}", end='') - - for x in range(4): - sys.stdout.flush() - time.sleep(0.25) - print(".", end='') - - if SIG_TRIGGER: - abort = input('\nDo you really want to abort (y/n)? ') - if abort.strip() != 'n': - exit(0) - - if SIG_TRIGGER is False: - sys.stdin.read() - SIG_TRIGGER = False - signal.signal(signal.SIGINT, sig_handler) - - # Put back the default/original signal handler now that we're done catching - # and interrupting SIGINT with "Do you really want to abort". - print() - signal.signal(signal.SIGINT, original_sigint_handler) + archinstall.do_countdown() """ Setup the blockdevice, filesystem (and optionally encryption). -- cgit v1.2.3-70-g09d2