Skip to content

Commit

Permalink
Improving debug log on countdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
theypsilon committed Mar 7, 2023
1 parent 580abae commit 10a73d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/update_all/countdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from multiprocessing import Process, Value

from update_all.cli_output_formatting import bold
from update_all.logger import Logger


@unique
Expand All @@ -39,6 +40,9 @@ def execute_count(self, n) -> CountdownOutcome:


class CountdownImpl(Countdown):
def __init__(self, logger: Logger):
self._logger = logger

def execute_count(self, count) -> CountdownOutcome:
try:
os_specifics = make_os_specifics()
Expand All @@ -49,11 +53,13 @@ def execute_count(self, count) -> CountdownOutcome:

child_process = Process(target=read_characters, args=(char, ends, os_specifics.context()), daemon=True)

print()
print(f" {bold('*')}Press <{bold('UP')}>, To enter the SETTINGS screen.")
print(f" {bold('*')}Press <{bold('DOWN')}>, To continue now.")
print()
except:
self._logger.print()
self._logger.print(f" {bold('*')}Press <{bold('UP')}>, To enter the SETTINGS screen.")
self._logger.print(f" {bold('*')}Press <{bold('DOWN')}>, To continue now.")
self._logger.print()
except Exception as e:
self._logger.debug(e)
self._logger.debug('Recovering error by suspending the countdown.')
return CountdownOutcome.CONTINUE

result = CountdownOutcome.CONTINUE
Expand Down
3 changes: 2 additions & 1 deletion src/update_all/update_all_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def create(self, env: dict[str, str]):
self._logger,
file_system,
os_utils,
CountdownImpl(),
CountdownImpl(self._logger),
settings_screen,
checker=checker,
store_provider=store_provider,
Expand Down Expand Up @@ -170,6 +170,7 @@ def _countdown_for_settings_screen(self) -> None:
self._print_sequence()
outcome = self._countdown.execute_count(self._store_provider.get().get_countdown_time())
if outcome == CountdownOutcome.SETTINGS_SCREEN:
self._logger.debug('Loading Settings Screen main menu.')
self._settings_screen.load_main_menu()
self._logger.print(CLEAR_SCREEN, end='')
self._print_sequence()
Expand Down

0 comments on commit 10a73d5

Please sign in to comment.