Prompt user on quit.

This commit is contained in:
Aldo Cortesi 2011-01-28 12:55:02 +13:00
parent 0742bc4fd0
commit 091db9cdf2
2 changed files with 18 additions and 9 deletions

View File

@ -1076,7 +1076,15 @@ class ConsoleMaster(controller.Master):
if self.nested:
self.view_connlist()
else:
raise Stop
self.prompt_onekey(
"Quit",
(
("yes", "y"),
("no", "n"),
),
self.quit,
)
k = None
elif k == "S":
self.path_prompt("Save flows: ", self.save_flows)
k = None
@ -1091,6 +1099,10 @@ class ConsoleMaster(controller.Master):
except (Stop, KeyboardInterrupt):
pass
def quit(self, a):
if a != "n":
raise Stop
def shutdown(self):
for i in self.state.flow_list:
i.kill()

View File

@ -80,10 +80,7 @@ if __name__ == '__main__':
m = console.ConsoleMaster(server, options)
for i in args:
msg = m.load_flows(i)
if msg:
print >> sys.stderr, msg
sys.exit(1)
m.load_flows(i)
m.run()