]> scripts.mit.edu Git - wizard.git/blob - wizard/install/interactive.py
Implement interactive mode without validation.
[wizard.git] / wizard / install / interactive.py
1 import getpass
2 import sys
3
4 class Controller(object):
5     def __init__(self, dir, schema, input):
6         self.dir = dir
7         self.schema = schema
8         self.input = input
9     def ask(self, options):
10         """
11         Interactively ask the user for information.
12         """
13         self.schema.commit(self.dir)
14         self.schema.fill(options)
15         for name, arg in self.schema.args.items():
16             if name in self.schema.provides:
17                 continue
18             if not arg.password:
19                 val = self.input.inputbox(arg.help + "\n\n" + name + ":")
20             else:
21                 val = self.input.passwordbox(arg.help + "\n\n" + name + " (cursor will not move):")
22             setattr(options, name, val)
23         self.schema.load(options)
24