]> scripts.mit.edu Git - wizard.git/blob - wizard/install/interactive.py
Remove string exception from remaster.
[wizard.git] / wizard / install / interactive.py
1 import getpass
2 import sys
3
4 def humanize(text):
5     return text.replace("_", " ").capitalize()
6
7 class Controller(object):
8     def __init__(self, dir, schema, input):
9         self.dir = dir
10         self.schema = schema
11         self.input = input
12     def ask(self, options):
13         """
14         Interactively ask the user for information.
15         """
16         self.schema.fill(options)
17         for name, arg in self.schema.args.items():
18             if name in self.schema.provides:
19                 continue
20             if getattr(options, name) is not None:
21                 continue
22             if not arg.password:
23                 val = self.input.inputbox(arg.prompt + "\n\n" + humanize(name) + ":")
24             else:
25                 while 1:
26                     val = self.input.passwordbox(arg.prompt + "\n\n" + humanize(name) + " (cursor will not move):")
27                     val2 = self.input.passwordbox("Please enter the password again (cursor will not move):")
28                     if val != val2:
29                         self.input.msgbox("Passwords didn't match.")
30                         continue
31                     break
32             setattr(options, name, val)
33         self.schema.load(options)
34