index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton.feeds+github@gmail.com> | 2020-10-18 13:08:24 +0200 |
---|---|---|
committer | Anton Hvornum <anton.feeds+github@gmail.com> | 2020-10-18 13:08:24 +0200 |
commit | fd3bcdd7dba73cdeedd60637b161c6c89f6d0e33 (patch) | |
tree | fa620bfd7175902638cc32d4ecd4774ffe9b5786 /archinstall/lib | |
parent | ea84565f8636c0f393e336dbbc93c15cfdba6895 (diff) | |
parent | b6c5942da69e5eeb3db60f1af40e9f33db6800e9 (diff) |
-rw-r--r-- | archinstall/lib/output.py | 6 | ||||
-rw-r--r-- | archinstall/lib/storage.py | 1 | ||||
-rw-r--r-- | archinstall/lib/tts.py | 36 | ||||
-rw-r--r-- | archinstall/lib/user_interaction.py | 28 |
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py index a2711f54..d1b418d9 100644 --- a/archinstall/lib/output.py +++ b/archinstall/lib/output.py @@ -1,5 +1,4 @@ import sys -from .tts import TTS # Found first reference here: https://stackoverflow.com/questions/7445658/how-to-detect-if-the-console-does-support-ansi-escape-codes-in-python # And re-used this: https://github.com/django/django/blob/master/django/core/management/color.py#L12 @@ -44,7 +43,4 @@ def log(*args, **kwargs): kwargs = {'bg' : 'black', 'fg': 'white', **kwargs} string = stylize_output(string, **kwargs) - print(string) - with TTS() as tts_instance: - if tts_instance.is_available: - tts_instance.speak(string.replace('-', '').strip().lstrip()) + print(string)
\ No newline at end of file diff --git a/archinstall/lib/storage.py b/archinstall/lib/storage.py new file mode 100644 index 00000000..2c621f83 --- /dev/null +++ b/archinstall/lib/storage.py @@ -0,0 +1 @@ +storage = {}
\ No newline at end of file diff --git a/archinstall/lib/tts.py b/archinstall/lib/tts.py deleted file mode 100644 index d94fbf1e..00000000 --- a/archinstall/lib/tts.py +++ /dev/null @@ -1,36 +0,0 @@ -class TTS(): - def __init__(self): - try: - import pyttsx3 - self._available = True - except: - self._available = False - - @property - def available(self): - return self._available - @property - def is_available(self): - return self._available - - @property - def volume(self): - return self.engine.getProperty('volume') - - @volume.setter - def volume(self, percentage): - self.engine.setProperty('volume', percentage/100) - return self.volume - - - def speak(self, phrase): - if self.available: - self.engine.say("I will speak this text") - engine.runAndWait() - - def __enter__(self): - self.engine = pyttsx3.init() - return self - - def __exit__(self, *args, **kwargs): - self.engine.stop()
\ No newline at end of file diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 23141fa9..e01859b3 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -5,6 +5,34 @@ from .locale_helpers import search_keyboard_layout ## TODO: Some inconsistencies between the selection processes. ## Some return the keys from the options, some the values? +def generic_select(options, input_text="Select one of the above by index or absolute value: ", sort=True): + """ + A generic select function that does not output anything + other than the options and their indexs. As an example: + + generic_select(["first", "second", "third option"]) + 1: first + 2: second + 3: third option + """ + + if type(options) == dict: options = list(options) + if sort: options = sorted(list(options)) + if len(options) <= 0: raise RequirementError('generic_select() requires at least one option to operate.') + + for index, option in enumerate(options): + print(f"{index}: {option}") + + selected_option = input(input_text) + if selected_option.isdigit(): + selected_option = options[int(selected_option)] + elif selected_option in options: + pass # We gave a correct absolute value + else: + raise RequirementError(f'Selected option "{selected_option}" does not exist in available options: {options}') + + return selected_option + def select_disk(dict_o_disks): """ Asks the user to select a harddrive from the `dict_o_disks` selection. |