Skip to content

Commit

Permalink
Convert print to tui prints
Browse files Browse the repository at this point in the history
  • Loading branch information
svartkanin committed Sep 21, 2024
1 parent 865abac commit 753eef4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
7 changes: 4 additions & 3 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .pacman import Pacman
from .plugins import plugins
from .storage import storage
from archinstall.tui.curses_menu import tui

if TYPE_CHECKING:
_: Any
Expand Down Expand Up @@ -105,9 +106,9 @@ def __exit__(self, exc_type, exc_val, exc_tb) -> bool:

# We avoid printing /mnt/<log path> because that might confuse people if they note it down
# and then reboot, and a identical log file will be found in the ISO medium anyway.
print(_("[!] A log file has been created here: {}").format(
os.path.join(storage['LOG_PATH'], storage['LOG_FILE'])))
print(_(" Please submit this issue (and file) to https://github.com/archlinux/archinstall/issues"))
log_file = os.path.join(storage['LOG_PATH'], storage['LOG_FILE'])
tui.print(str(_("[!] A log file has been created here: {}").format(log_file)))
tui.print(str(_('Please submit this issue (and file) to https://github.com/archlinux/archinstall/issues')))
raise exc_val

if not (missing_steps := self.post_install_check()):
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/menu/abstract_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from ..output import error
from ..output import unicode_ljust
from archinstall.tui.curses_menu import tui
from archinstall.tui import (
MenuItemGroup, MenuItem, SelectMenu,
PreviewStyle, FrameProperties, FrameStyle,
Expand Down Expand Up @@ -173,8 +174,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None:
# TODO: skip processing when it comes from a planified exit
if len(args) >= 2 and args[1]:
error(args[1])
print(
" Please submit this issue (and file) to https://github.com/archlinux/archinstall/issues")
tui.print("Please submit this issue (and file) to https://github.com/archlinux/archinstall/issues")
raise args[1]

self._sync_all_to_ds()
Expand Down
3 changes: 2 additions & 1 deletion archinstall/lib/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .exceptions import SysCallError, DownloadTimeout
from .output import error, info
from .pacman import Pacman
from .output import debug


class DownloadTimer():
Expand Down Expand Up @@ -189,7 +190,7 @@ def ping(hostname, timeout=5) -> int:
latency = round((time.time() - started) * 1000)
break
except socket.error as error:
print(f"Error: {error}")
debug(f"Error: {error}")
break

icmp_socket.close()
Expand Down
7 changes: 6 additions & 1 deletion archinstall/scripts/unattended.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import archinstall
from archinstall import info
from archinstall import profile
from archinstall.tui.curses_menu import tui


tui.init()


for p in profile.profile_handler.get_mac_addr_profiles():
# Tailored means it's a match for this machine
Expand All @@ -12,7 +17,7 @@

print('Starting install in:')
for i in range(10, 0, -1):
print(f'{i}...')
tui.print(f'{i}...')
time.sleep(1)

install_session = archinstall.storage['installation_session']
Expand Down
7 changes: 6 additions & 1 deletion examples/mac_address_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import archinstall
from archinstall import profile, info
from archinstall.tui.curses_menu import tui


tui.init()


for _profile in profile.profile_handler.get_mac_addr_profiles():
# Tailored means it's a match for this machine
Expand All @@ -11,7 +16,7 @@

print('Starting install in:')
for i in range(10, 0, -1):
print(f'{i}...')
tui.print(f'{i}...')
time.sleep(1)

install_session = archinstall.storage['installation_session']
Expand Down

0 comments on commit 753eef4

Please sign in to comment.