console: use replay count commands in statusbar

Also add a periodic refresh every 0.5 seconds for the statusbar. This is in
addition to refreshes upon event update notifications, and picks up replay
status changes not linked to flow events.
This commit is contained in:
Aldo Cortesi 2018-05-02 09:32:27 +12:00
parent 42b04a5413
commit e963408434
2 changed files with 9 additions and 4 deletions

View File

@ -100,7 +100,7 @@ class ServerPlayback:
ctx.master.addons.trigger("update", []) ctx.master.addons.trigger("update", [])
@command.command("replay.server.count") @command.command("replay.server.count")
def count(self): def count(self) -> int:
return sum([len(i) for i in self.flowmap.values()]) return sum([len(i) for i in self.flowmap.values()])
def _hash(self, flow): def _hash(self, flow):

View File

@ -158,6 +158,7 @@ class ActionBar(urwid.WidgetWrap):
class StatusBar(urwid.WidgetWrap): class StatusBar(urwid.WidgetWrap):
REFRESHTIME = 0.5 # Timed refresh time in seconds
keyctx = "" keyctx = ""
def __init__( def __init__(
@ -173,7 +174,11 @@ class StatusBar(urwid.WidgetWrap):
master.options.changed.connect(self.sig_update) master.options.changed.connect(self.sig_update)
master.view.focus.sig_change.connect(self.sig_update) master.view.focus.sig_change.connect(self.sig_update)
master.view.sig_view_add.connect(self.sig_update) master.view.sig_view_add.connect(self.sig_update)
self.refresh()
def refresh(self):
self.redraw() self.redraw()
signals.call_in.send(seconds=self.REFRESHTIME, callback=self.refresh)
def sig_update(self, sender, flow=None, updated=None): def sig_update(self, sender, flow=None, updated=None):
self.redraw() self.redraw()
@ -184,7 +189,7 @@ class StatusBar(urwid.WidgetWrap):
def get_status(self): def get_status(self):
r = [] r = []
sreplay = self.master.addons.get("serverplayback") sreplay = self.master.commands.call("replay.server.count")
creplay = self.master.commands.call("replay.client.count") creplay = self.master.commands.call("replay.client.count")
if len(self.master.options.setheaders): if len(self.master.options.setheaders):
@ -197,10 +202,10 @@ class StatusBar(urwid.WidgetWrap):
r.append("[") r.append("[")
r.append(("heading_key", "cplayback")) r.append(("heading_key", "cplayback"))
r.append(":%s]" % creplay) r.append(":%s]" % creplay)
if sreplay.count(): if sreplay:
r.append("[") r.append("[")
r.append(("heading_key", "splayback")) r.append(("heading_key", "splayback"))
r.append(":%s]" % sreplay.count()) r.append(":%s]" % sreplay)
if self.master.options.ignore_hosts: if self.master.options.ignore_hosts:
r.append("[") r.append("[")
r.append(("heading_key", "I")) r.append(("heading_key", "I"))