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]
count = True
# 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-line-length = 236
show-source = True

View File

@ -1,7 +1,7 @@
default_stages: ['commit']
repos:
- repo: https://github.com/pycqa/autoflake
rev: v2.1.1
rev: v2.3.1
hooks:
- id: autoflake
args: [
@ -13,7 +13,7 @@ repos:
require_serial: true
fail_fast: true
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
# general hooks:
- 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-docstring-first # Checks for a common error of placing code before the docstring
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
args: [--config=.flake8]
fail_fast: true
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.1.1
rev: v1.10.0
hooks:
- id: mypy
args: [--config=pyproject.toml]

View File

@ -3,6 +3,7 @@ import importlib
import os
import sys
import time
import curses
import traceback
from argparse import ArgumentParser, Namespace
from pathlib import Path
@ -327,18 +328,44 @@ def main():
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():
exc = None
try:
main()
except Exception as e:
err = ''.join(traceback.format_exception(e))
error(err)
exc = e
finally:
# restore the terminal to the original state
_shutdown_curses()
text = (
'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'
)
if exc:
err = ''.join(traceback.format_exception(exc))
error(err)
warn(text)
exit(1)
text = (
'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.Selection: return choice.single_value
return []
return []

View File

File diff suppressed because it is too large Load Diff