~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to setup/configure.py

setup.configure: Replaced use of legacy conf.py for loading existing values.
    Now goes directly through the new ivle.config module.
    Removed CONFIG_OPTIONS dict mapping new names to legacy names.
ivle.config: Added Config.get_by_path to facilitate this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import uuid
35
35
 
36
36
from setup.util import query_user
 
37
import ivle.config
37
38
 
38
39
import configobj
39
40
 
40
 
# This dict maps new config option paths ('section/option_name') to legacy
41
 
# config option names ('option_name'). 
42
 
# NOTE: This is the inverse of the dictionary from ivle/conf/conf.py.
43
 
CONFIG_OPTIONS = {
44
 
    'urls/root': 'root_dir',
45
 
    'paths/prefix': 'prefix',
46
 
    'paths/data': 'data_path',
47
 
    'paths/logs': 'log_path',
48
 
    'paths/site_packages': 'python_site_packages_override',
49
 
    'urls/public_host': 'public_host',
50
 
    'os/allowed_uids': 'allowed_uids',
51
 
    'database/host': 'db_host',
52
 
    'database/port': 'db_port',
53
 
    'database/name': 'db_dbname',
54
 
    'plugins/forum/dbname': 'db_forumdbname',
55
 
    'database/username': 'db_user',
56
 
    'database/password': 'db_password',
57
 
    'auth/modules': 'auth_modules',
58
 
    'auth/ldap_url': 'ldap_url',
59
 
    'auth/ldap_format_string': 'ldap_format_string',
60
 
    'auth/subject_pulldown_modules': 'subject_pulldown_modules',
61
 
    'urls/svn_addr': 'svn_addr',
62
 
    'usrmgt/host': 'usrmgt_host',
63
 
    'usrmgt/port': 'usrmgt_port',
64
 
    'usrmgt/magic': 'usrmgt_magic',
65
 
    'plugins/forum/secret': 'forum_secret',
66
 
}
67
 
 
68
41
# conf_options maps option names to values
69
42
conf_options = {}
70
43
 
261
234
    # The reason for this is that these settings are used by other phases
262
235
    # of setup besides conf, so we need to know them.
263
236
    # Also this allows you to hit Return to accept the existing value.
264
 
    try:
265
 
        confmodule = __import__("ivle/conf/conf")
266
 
        for opt in config_options:
267
 
            try:
268
 
                conf_options[opt.option_name] = \
269
 
                    confmodule.__dict__[CONFIG_OPTIONS[opt.option_name]]
270
 
            except:
271
 
                conf_options[opt.option_name] = opt.default
272
 
    except ImportError:
273
 
        # Just set reasonable defaults
274
 
        for opt in config_options:
 
237
    conf = ivle.config.Config()
 
238
    for opt in config_options:
 
239
        try:
 
240
            conf_options[opt.option_name] = conf.get_by_path(opt.option_name)
 
241
        except KeyError:
275
242
            conf_options[opt.option_name] = opt.default
276
243
 
277
244
    # Set up some variables