Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-04-08 21:14:19 +0200
committerAnton Hvornum <anton@hvornum.se>2021-04-08 21:14:19 +0200
commitb5245b31fec9c19a16a8b00233afb1cfee1499fa (patch)
tree7d01f4721f6b8473c0f72c8dd725e7724c594c20 /archinstall/lib
parentae2da06075763d388c303e8cd7914694454aa8fb (diff)
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.
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/user_interaction.py44
1 files changed, 40 insertions, 4 deletions
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 3830962c..33abbefb 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -1,4 +1,5 @@
import getpass, pathlib, os, shutil, re
+import sys, time, signal
from .exceptions import *
from .profiles import Profile
from .locale_helpers import search_keyboard_layout
@@ -19,14 +20,49 @@ def get_longest_option(options):
return max([len(x) for x in options])
def check_for_correct_username(username):
- if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32:
- return True
- log(
+ if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32:
+ return True
+ log(
"The username you entered is invalid. Try again",
level=LOG_LEVELS.Warning,
fg='red'
)
- return False
+ return False
+
+def do_countdown():
+ 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)
+
+ 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)
+ print()
+ signal.signal(signal.SIGINT, original_sigint_handler)
+ return True
def get_password(prompt="Enter a password: "):
while (passwd := getpass.getpass(prompt)):