index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton.feeds+github@gmail.com> | 2020-10-18 20:49:44 +0200 |
---|---|---|
committer | Anton Hvornum <anton.feeds+github@gmail.com> | 2020-10-18 20:49:44 +0200 |
commit | 2df4347b44ff6e45ed6b4a66332efae51056c2ef (patch) | |
tree | ecba1493b1a107488e516c7e6e4a7f43aa4ef47a /examples | |
parent | 479881a5a25576725a822d805d556a7f318a5e48 (diff) |
-rw-r--r-- | examples/guided.py | 31 |
diff --git a/examples/guided.py b/examples/guided.py index 12d34194..067d591f 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,5 +1,20 @@ import archinstall -import getpass, time, json, sys +import getpass, time, json, sys, signal +from select import epoll, EPOLLIN + +""" +This signal-handler chain (and global variable) +is used to trigger the "Are you sure you want to abort?" question. +""" +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) +signal.signal(signal.SIGINT, sig_handler) def perform_installation(device, boot_partition, language, mirrors): """ @@ -148,7 +163,11 @@ print() Issue a final warning before we continue with something un-revertable. We mention the drive one last time, and count from 5 to 0. """ + print(f' ! Formatting {harddrive} in ', end='') + +poller = epoll() +poller.register(sys.stdin.fileno(), EPOLLIN) for i in range(5, 0, -1): print(f"{i}", end='') @@ -156,6 +175,16 @@ for i in range(5, 0, -1): sys.stdout.flush() time.sleep(0.25) print(".", end='') + + if list(poller.poll(0.25)) or 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) print() """ Setup the blockdevice, filesystem (and optionally encryption). |