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

« back to all changes in this revision

Viewing changes to setup/configure.py

Replaced Python config files (conf.py) with new config files system, using
    configobj (INI-file style config files).

setup.py config now produces ./etc/ivle.conf, a new-style config file.
ivle/conf/conf.py is now part of the IVLE source code. It reads the new config
file and provides the same legacy interface, so all of IVLE still functions,
including setup.py config.

Added /etc to the source tree (config files will be stored here).
Added configobj as a dependency in doc/setup/install_proc.txt.

setup.py install copies ./etc/ivle.conf into /etc/ivle/ivle.conf.

Removed boilerplate code generation from setup/configure.py (that code is now
part of ivle/conf/conf.py which is now in the source tree).

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
from setup.util import query_user
37
37
 
 
38
import configobj
 
39
 
38
40
class ConfigOption:
39
41
    """A configuration option; one of the things written to conf.py."""
40
42
    def __init__(self, option_name, default, prompt, comment, ask=True):
248
250
    cwd = os.getcwd()
249
251
 
250
252
    # the files that will be created/overwritten
251
 
    conffile = os.path.join(cwd, "ivle/conf/conf.py")
 
253
    conffile = os.path.join(cwd, "etc/ivle.conf")
252
254
    conf_hfile = os.path.join(cwd, "bin/trampoline/conf.h")
253
255
    phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php")
254
256
 
323
325
    # Generate the forum secret
324
326
    forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest()
325
327
 
326
 
    # Write lib/conf/conf.py
327
 
 
328
 
    conf = open(conffile, "w")
329
 
 
330
 
    conf.write("""# IVLE Configuration File
331
 
# conf.py
332
 
# Miscellaneous application settings
333
 
 
334
 
import os
335
 
import sys
336
 
""")
 
328
    # Write ./etc/ivle.conf
 
329
 
 
330
    conf = configobj.ConfigObj()
 
331
    conf.filename = conffile
 
332
 
 
333
    conf.initial_comment = ["# IVLE Configuration File"]
 
334
 
337
335
    for opt in config_options:
338
 
        conf.write('%s\n%s = %r\n' % (opt.comment, opt.option_name,
339
 
            globals()[opt.option_name]))
 
336
        conf[opt.option_name] = globals()[opt.option_name]
 
337
        conf.comments[opt.option_name] = opt.comment.split('\n')
340
338
 
341
339
    # Add the forum secret to the config file (regenerated each config)
342
 
    conf.write('forum_secret = "%s"\n\n' % (forum_secret))
343
 
 
344
 
    write_conf_file_boilerplate(conf)
345
 
 
346
 
    conf.close()
 
340
    conf['forum_secret'] = forum_secret
 
341
 
 
342
    conf.write()
347
343
 
348
344
    print "Successfully wrote %s" % conffile
349
345
 
432
428
    print
433
429
    
434
430
    return 0
435
 
 
436
 
def write_conf_file_boilerplate(conf_file):
437
 
    conf_file.write("""\
438
 
### Below is boilerplate code, appended by ./setup.py config ###
439
 
 
440
 
# Path where architecture-dependent data (including non-user-executable
441
 
# binaries) is installed.
442
 
lib_path = os.path.join(prefix, 'lib/ivle')
443
 
 
444
 
# Path where arch-independent data is installed.
445
 
share_path = os.path.join(prefix, 'share/ivle')
446
 
 
447
 
# Path where user-executable binaries are installed.
448
 
bin_path = os.path.join(prefix, 'bin')
449
 
 
450
 
# 'site-packages' directory in Python, where Python libraries are to be
451
 
# installed.
452
 
if python_site_packages_override is None:
453
 
    PYTHON_VERSION = sys.version[0:3]   # eg. "2.5"
454
 
    python_site_packages = os.path.join(prefix,
455
 
                               'lib/python%s/site-packages' % PYTHON_VERSION)
456
 
else:
457
 
    python_site_packages = python_site_packages_override
458
 
 
459
 
# In the local file system, where the student/user jails will be mounted.
460
 
# Only a single copy of the jail's system components will be stored here -
461
 
# all user jails will be virtually mounted here.
462
 
jail_base = os.path.join(data_path, 'jailmounts')
463
 
 
464
 
# In the local file system, where are the student/user file spaces located.
465
 
# The user jails are expected to be located immediately in subdirectories of
466
 
# this location. Note that no complete jails reside here - only user
467
 
# modifications.
468
 
jail_src_base = os.path.join(data_path, 'jails')
469
 
 
470
 
# In the local file system, where the template system jail will be stored.
471
 
jail_system = os.path.join(jail_src_base, '__base__')
472
 
 
473
 
# In the local file system, where the template system jail will be stored.
474
 
jail_system_build = os.path.join(jail_src_base, '__base_build__')
475
 
 
476
 
# In the local file system, where the subject content files are located.
477
 
# (The 'subjects' and 'exercises' directories).
478
 
content_path = os.path.join(data_path, 'content')
479
 
 
480
 
# In the local file system, where are the per-subject file spaces located.
481
 
# The individual subject directories are expected to be located immediately
482
 
# in subdirectories of this location.
483
 
subjects_base = os.path.join(content_path, 'subjects')
484
 
 
485
 
# In the local file system, where are the subject-independent exercise sheet
486
 
# file spaces located.
487
 
exercises_base = os.path.join(content_path, 'exercises')
488
 
 
489
 
# In the local file system, where the system notices are stored (such as terms
490
 
# of service and MOTD).
491
 
notices_path = os.path.join(data_path, 'notices')
492
 
 
493
 
# In the local file system, where is the Terms of Service document located.
494
 
tos_path = os.path.join(notices_path, 'tos.html')
495
 
 
496
 
# In the local file system, where is the Message of the Day document
497
 
# located. This is an HTML file (just the body fragment), which will
498
 
# be displayed on the login page. It is optional.
499
 
motd_path = os.path.join(notices_path, 'motd.html')
500
 
 
501
 
# The location of all the subversion config and repositories.
502
 
svn_path = os.path.join(data_path, 'svn')
503
 
 
504
 
# The location of the subversion configuration file used by
505
 
# apache to host the user repositories.
506
 
svn_conf = os.path.join(svn_path, 'svn.conf')
507
 
 
508
 
# The location of the subversion configuration file used by
509
 
# apache to host the user repositories.
510
 
svn_group_conf = os.path.join(svn_path, 'svn-group.conf')
511
 
 
512
 
# The root directory for the subversion repositories.
513
 
svn_repo_path = os.path.join(svn_path, 'repositories')
514
 
 
515
 
# The location of the password file used to authenticate users
516
 
# of the subversion repository from the ivle server.
517
 
svn_auth_ivle = os.path.join(svn_path, 'ivle.auth')
518
 
""")