Skip to content

Commit

Permalink
pw_watch: Fix startup exception
Browse files Browse the repository at this point in the history
A past CL (108730) introduced a better log rendering timer but
forgot to add that functionality to pw watch --fullscreen

Change-Id: I427909acb07e47f220640d6e5ff93c3060030d90
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/109713
Pigweed-Auto-Submit: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
  • Loading branch information
AnthonyDiGirolamo authored and CQ Bot Account committed Sep 9, 2022
1 parent 40e12be commit 4e7d9a1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pw_watch/py/pw_watch/watch_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from pathlib import Path
import re
import sys
import time
from typing import List, NoReturn, Optional

from prompt_toolkit.application import Application
Expand Down Expand Up @@ -109,6 +110,9 @@ def __init__(self,
self._build_error_count = 0
self._errors_in_output = False

self.log_ui_update_frequency = 0.1 # 10 FPS
self._last_ui_update_time = time.time()

self.ninja_log_pane = LogPane(application=self,
pane_title='Pigweed Watch')
self.ninja_log_pane.add_log_handler(_NINJA_LOG, level_name='INFO')
Expand Down Expand Up @@ -255,6 +259,16 @@ def _quit_with_confirm(_event):
plugin_logger_name='pw_watch_stdout_checker',
)

def logs_redraw(self):
emit_time = time.time()
# Has enough time passed since last UI redraw due to new logs?
if emit_time > self._last_ui_update_time + self.log_ui_update_frequency:
# Update last log time
self._last_ui_update_time = emit_time

# Trigger Prompt Toolkit UI redraw.
self.redraw_ui()

def jump_to_error(self, backwards: bool = False) -> None:
if not self.ninja_log_pane.log_view.search_text:
self.ninja_log_pane.log_view.set_search_regex(
Expand Down

0 comments on commit 4e7d9a1

Please sign in to comment.