mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
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:
parent
42b04a5413
commit
e963408434
@ -100,7 +100,7 @@ class ServerPlayback:
|
||||
ctx.master.addons.trigger("update", [])
|
||||
|
||||
@command.command("replay.server.count")
|
||||
def count(self):
|
||||
def count(self) -> int:
|
||||
return sum([len(i) for i in self.flowmap.values()])
|
||||
|
||||
def _hash(self, flow):
|
||||
|
@ -158,6 +158,7 @@ class ActionBar(urwid.WidgetWrap):
|
||||
|
||||
|
||||
class StatusBar(urwid.WidgetWrap):
|
||||
REFRESHTIME = 0.5 # Timed refresh time in seconds
|
||||
keyctx = ""
|
||||
|
||||
def __init__(
|
||||
@ -173,7 +174,11 @@ class StatusBar(urwid.WidgetWrap):
|
||||
master.options.changed.connect(self.sig_update)
|
||||
master.view.focus.sig_change.connect(self.sig_update)
|
||||
master.view.sig_view_add.connect(self.sig_update)
|
||||
self.refresh()
|
||||
|
||||
def refresh(self):
|
||||
self.redraw()
|
||||
signals.call_in.send(seconds=self.REFRESHTIME, callback=self.refresh)
|
||||
|
||||
def sig_update(self, sender, flow=None, updated=None):
|
||||
self.redraw()
|
||||
@ -184,7 +189,7 @@ class StatusBar(urwid.WidgetWrap):
|
||||
def get_status(self):
|
||||
r = []
|
||||
|
||||
sreplay = self.master.addons.get("serverplayback")
|
||||
sreplay = self.master.commands.call("replay.server.count")
|
||||
creplay = self.master.commands.call("replay.client.count")
|
||||
|
||||
if len(self.master.options.setheaders):
|
||||
@ -197,10 +202,10 @@ class StatusBar(urwid.WidgetWrap):
|
||||
r.append("[")
|
||||
r.append(("heading_key", "cplayback"))
|
||||
r.append(":%s]" % creplay)
|
||||
if sreplay.count():
|
||||
if sreplay:
|
||||
r.append("[")
|
||||
r.append(("heading_key", "splayback"))
|
||||
r.append(":%s]" % sreplay.count())
|
||||
r.append(":%s]" % sreplay)
|
||||
if self.master.options.ignore_hosts:
|
||||
r.append("[")
|
||||
r.append(("heading_key", "I"))
|
||||
|
Loading…
Reference in New Issue
Block a user