stop console from crashing on input before it is started

This commit is contained in:
Jimmy Kiselak 2015-11-23 15:11:34 -05:00
parent 7a3bdf93e9
commit c8afce2a3a

View file

@ -12,6 +12,8 @@ class ConsoleControl(basic.LineReceiver):
def __init__(self):
self.connected = False
self.buffer = []
self.command_handlers = {}
self.current_handler = None
def start(self, command_handlers):
self.command_handlers = {h.command: h for h in command_handlers}
@ -83,6 +85,8 @@ class ConsoleControl(basic.LineReceiver):
self.show_prompt()
def lineReceived(self, line):
if not self.command_handlers:
return
if self.current_handler is None:
words = line.split()
if len(words) == 0: