From 3b4ee7cd77cb3e79308b87e306b91c4069ff970f Mon Sep 17 00:00:00 2001 From: Daniel Edgecumbe Date: Sun, 1 Oct 2017 03:17:00 +0100 Subject: [PATCH] [net] Inform user in the event that network information has not loaded yet --- net.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/net.py b/net.py index b20d818..d501c88 100644 --- a/net.py +++ b/net.py @@ -39,6 +39,20 @@ class NetView(view.View): i += 1 + if not self._nettotals_history or len(deltas) < 1: + await self._draw_no_chart() + else: + await self._draw_chart(deltas) + + self._draw_pad_to_screen() + + async def _draw_no_chart(self): + CRED = curses.color_pair(3) + CBOLD = curses.A_BOLD + self._pad.addstr(0, 1, "no network information yet", CRED + CBOLD) + self._pad.addstr(1, 1, "please wait a few seconds...", CRED) + + async def _draw_chart(self, deltas): ph, pw = 20, 100 plot_height = (ph-3) // 2 plot_offset = plot_height @@ -85,8 +99,6 @@ class NetView(view.View): for y in range(0, height): self._pad.addstr(plot_offset+y, i+12, " ", CGREEN + CREVERSE) - self._draw_pad_to_screen() - async def on_nettotals(self, key, obj): try: self._nettotals_history.append(obj["result"])