Skip to content

Commit b02eed8

Browse files
committed
m1n1.shell: Add poll_func hook
Signed-off-by: Hector Martin <[email protected]>
1 parent 5921631 commit b02eed8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

proxyclient/m1n1/shell.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __init__(self, locals=None, filename="<console>",
1818
code.InteractiveConsole.__init__(self, locals, filename)
1919
self.histfile = histfile
2020
self.init_history(histfile)
21+
self.poll_func = None
2122

2223
def init_history(self, histfile):
2324
readline.parse_and_bind("tab: complete")
@@ -37,6 +38,8 @@ def showtraceback(self):
3738

3839
def runcode(self, code):
3940
super().runcode(code)
41+
if self.poll_func:
42+
self.poll_func()
4043
if "mon" in self.locals:
4144
try:
4245
self.locals["mon"].poll()
@@ -118,7 +121,7 @@ def help_cmd(arg=None):
118121
#locals is a dictionary for constructing the
119122
# InteractiveConsole with. It adds in the callables
120123
# in proxy utils iface and sysreg into locals
121-
def run_shell(locals, msg=None, exitmsg=None):
124+
def run_shell(locals, msg=None, exitmsg=None, poll_func=None):
122125
saved_display = sys.displayhook
123126
try:
124127
def display(val):
@@ -189,6 +192,7 @@ def display(val):
189192
clist[obj_name] = desc
190193

191194
con = HistoryConsole(locals)
195+
con.poll_func = poll_func
192196
try:
193197
con.interact(msg, exitmsg)
194198
except ExitConsole as e:

0 commit comments

Comments
 (0)