]> scripts.mit.edu Git - wizard.git/blob - wizard/install/interactive.py
Fix double-slash in URLs, and broken command line options.
[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.commit(self.dir)
17         self.schema.fill(options)
18         for name, arg in self.schema.args.items():
19             if name in self.schema.provides:
20                 continue
21             if getattr(options, name) is not None:
22                 continue
23             if not arg.password:
24                 val = self.input.inputbox(arg.help + "\n\n" + humanize(name) + ":")
25             else:
26                 while 1:
27                     val = self.input.passwordbox(arg.help + "\n\n" + humanize(name) + " (cursor will not move):")
28                     val2 = self.input.passwordbox("Please enter the password again (cursor will not move):")
29                     if val != val2:
30                         self.input.msgbox("Passwords didn't match.")
31                         continue
32                     break
33             setattr(options, name, val)
34         self.schema.load(options)
35