New menu implementation with curses (#2506)

* TUI

* Fix menu iterating

* Add help menu

* Add column menu

* Fix filter

* Tweaked import statement

---------

Co-authored-by: Anton Hvornum <torxed@archlinux.org>
This commit is contained in:
Daniel Girtler 2024-06-07 06:31:15 +10:00 committed by GitHub
parent 6524ada762
commit 5c180f0741
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 1231 additions and 15 deletions

View File

@ -1,7 +1,7 @@
[flake8] [flake8]
count = True count = True
# Several of the following could be autofixed or improved by running the code through psf/black # Several of the following could be autofixed or improved by running the code through psf/black
ignore = E123,E126,E128,E203,E231,E261,E302,E402,E722,F541,W191,W292,W293,W503 ignore = E123,E126,E128,E203,E231,E261,E302,E402,E722,F541,W191,W292,W293,W503,W504
max-complexity = 40 max-complexity = 40
max-line-length = 236 max-line-length = 236
show-source = True show-source = True

View File

@ -1,7 +1,7 @@
default_stages: ['commit'] default_stages: ['commit']
repos: repos:
- repo: https://github.com/pycqa/autoflake - repo: https://github.com/pycqa/autoflake
rev: v2.1.1 rev: v2.3.1
hooks: hooks:
- id: autoflake - id: autoflake
args: [ args: [
@ -13,7 +13,7 @@ repos:
require_serial: true require_serial: true
fail_fast: true fail_fast: true
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.5.0
hooks: hooks:
# general hooks: # general hooks:
- id: check-added-large-files # Prevent giant files from being committed - id: check-added-large-files # Prevent giant files from being committed
@ -29,13 +29,13 @@ repos:
- id: check-ast # Simply check whether files parse as valid python - id: check-ast # Simply check whether files parse as valid python
- id: check-docstring-first # Checks for a common error of placing code before the docstring - id: check-docstring-first # Checks for a common error of placing code before the docstring
- repo: https://github.com/pycqa/flake8 - repo: https://github.com/pycqa/flake8
rev: 6.0.0 rev: 7.0.0
hooks: hooks:
- id: flake8 - id: flake8
args: [--config=.flake8] args: [--config=.flake8]
fail_fast: true fail_fast: true
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.1.1 rev: v1.10.0
hooks: hooks:
- id: mypy - id: mypy
args: [--config=pyproject.toml] args: [--config=pyproject.toml]

View File

@ -3,6 +3,7 @@ import importlib
import os import os
import sys import sys
import time import time
import curses
import traceback import traceback
from argparse import ArgumentParser, Namespace from argparse import ArgumentParser, Namespace
from pathlib import Path from pathlib import Path
@ -327,18 +328,44 @@ def main():
importlib.import_module(mod_name) importlib.import_module(mod_name)
def _shutdown_curses():
try:
curses.nocbreak()
try:
from archinstall.tui.curses_menu import tui
tui.screen.keypad(False)
except Exception:
pass
curses.echo()
curses.curs_set(True)
curses.endwin()
except Exception:
# this may happen when curses has not been initialized
pass
def run_as_a_module(): def run_as_a_module():
exc = None
try: try:
main() main()
except Exception as e: except Exception as e:
err = ''.join(traceback.format_exception(e)) exc = e
error(err) finally:
# restore the terminal to the original state
_shutdown_curses()
text = ( if exc:
'Archinstall experienced the above error. If you think this is a bug, please report it to\n' err = ''.join(traceback.format_exception(exc))
'https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".\n\n' error(err)
'Hint: To extract the log from a live ISO \ncurl -F\'file=@/var/log/archinstall/install.log\' https://0x0.st\n'
)
warn(text) text = (
exit(1) 'Archinstall experienced the above error. If you think this is a bug, please report it to\n'
'https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".\n\n'
'Hint: To extract the log from a live ISO \ncurl -F\'file=@/var/log/archinstall/install.log\' https://0x0.st\n'
)
warn(text)
exit(1)

View File

@ -206,4 +206,4 @@ def select_additional_repositories(preset: List[str]) -> List[str]:
case MenuSelectionType.Reset: return [] case MenuSelectionType.Reset: return []
case MenuSelectionType.Selection: return choice.single_value case MenuSelectionType.Selection: return choice.single_value
return [] return []

View File

File diff suppressed because it is too large Load Diff