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

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: mattgiuca
  • Date: 2008-02-05 01:41:15 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:409
Moved www/conf and www/common to a new directory lib. This separates the "web"
part of IVLE from what is becoming less web oriented (at least from Apache's
standpoint).
Modified setup.py to install this lib directory correctly and write conf in
the right place. Also adds the lib directory to ivle.pth.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
# Configures IVLE with machine-specific details, most notably, various paths.
36
36
# Either prompts the administrator for these details or accepts them as
37
37
# command-line args.
38
 
# Creates www/conf/conf.py and trampoline/conf.h.
 
38
# Creates lib/conf/conf.py and trampoline/conf.h.
39
39
 
40
40
# setup.py build
41
41
# Compiles all files and sets up a jail template in the source directory.
70
70
 
71
71
# Import modules from the website is tricky since they're in the www
72
72
# directory.
73
 
sys.path.append(os.path.join(os.getcwd(), 'www'))
 
73
sys.path.append(os.path.join(os.getcwd(), 'lib'))
74
74
import conf
75
75
import common.makeuser
76
76
 
228
228
# Database username"""))
229
229
config_options.append(ConfigOption("db_password", "",
230
230
    """Password for DB server login:
231
 
    (Caution: This password is stored in plaintext in www/conf/conf.py)""",
 
231
    (Caution: This password is stored in plaintext in lib/conf/conf.py)""",
232
232
    """
233
233
# Database password"""))
234
234
 
237
237
# of setup besides conf, so we need to know them.
238
238
# Also this allows you to hit Return to accept the existing value.
239
239
try:
240
 
    confmodule = __import__("www/conf/conf")
 
240
    confmodule = __import__("lib/conf/conf")
241
241
    for opt in config_options:
242
242
        try:
243
243
            globals()[opt.option_name] = confmodule.__dict__[opt.option_name]
352
352
to rebuild/install), just provide ivle_install_dir as the IVLE trunk
353
353
directory, and run build/install one time.
354
354
 
355
 
Creates www/conf/conf.py and trampoline/conf.h.
 
355
Creates lib/conf/conf.py and trampoline/conf.h.
356
356
 
357
357
Args are:"""
358
358
        for opt in config_options:
402
402
def listmake(args):
403
403
    # We build two separate lists, by walking www and console
404
404
    list_www = build_list_py_files('www')
 
405
    list_lib = build_list_py_files('lib')
405
406
    list_console = build_list_py_files('console')
406
407
    list_subjects = build_list_py_files('subjects', no_top_level=True)
407
408
    list_problems = build_list_py_files('problems', no_top_level=True)
408
409
    # Make sure that the files generated by conf are in the list
409
410
    # (since listmake is typically run before conf)
410
 
    if "www/conf/conf.py" not in list_www:
411
 
        list_www.append("www/conf/conf.py")
 
411
    if "lib/conf/conf.py" not in list_lib:
 
412
        list_www.append("lib/conf/conf.py")
412
413
    # Make sure that console/python-console is in the list
413
414
    if "console/python-console" not in list_console:
414
415
        list_console.append("console/python-console")
431
432
list_www = """)
432
433
        writelist_pretty(file, list_www)
433
434
        file.write("""
 
435
# List of all installable files in lib directory.
 
436
list_lib = """)
 
437
        writelist_pretty(file, list_lib)
 
438
        file.write("""
434
439
# List of all installable files in console directory.
435
440
list_console = """)
436
441
        writelist_pretty(file, list_console)
494
499
 
495
500
    cwd = os.getcwd()
496
501
    # the files that will be created/overwritten
497
 
    conffile = os.path.join(cwd, "www/conf/conf.py")
 
502
    conffile = os.path.join(cwd, "lib/conf/conf.py")
498
503
    conf_hfile = os.path.join(cwd, "trampoline/conf.h")
499
504
 
500
505
    # Get command-line arguments to avoid asking questions.
551
556
        "Must be an integer between 0 and 65535." % repr(db_port))
552
557
        return 1
553
558
 
554
 
    # Write www/conf/conf.py
 
559
    # Write lib/conf/conf.py
555
560
 
556
561
    try:
557
562
        conf = open(conffile, "w")
570
575
        print "IO error(%s): %s" % (errno, strerror)
571
576
        sys.exit(1)
572
577
 
573
 
    print "Successfully wrote www/conf/conf.py"
 
578
    print "Successfully wrote lib/conf/conf.py"
574
579
 
575
580
    # Write trampoline/conf.h
576
581
 
689
694
    # chown trampoline to root and set setuid bit
690
695
    action_chown_setuid(tramppath, dry)
691
696
 
692
 
    # Copy the www directory using the list
 
697
    # Copy the www and lib directories using the list
693
698
    action_copylist(install_list.list_www, ivle_install_dir, dry)
 
699
    action_copylist(install_list.list_lib, ivle_install_dir, dry)
694
700
 
695
701
    if not nojail:
696
702
        # Copy the local jail directory built by the build action
709
715
    ivle_pth = os.path.join(sys.prefix,
710
716
        "lib/python%s/site-packages/ivle.pth" % PYTHON_VERSION)
711
717
    ivle_www = os.path.join(ivle_install_dir, "www")
 
718
    ivle_lib = os.path.join(ivle_install_dir, "lib")
712
719
    write_ivle_pth = True
 
720
    write_ivle_lib_pth = True
713
721
    try:
714
722
        file = open(ivle_pth, 'r')
715
723
        for line in file:
716
724
            if line.strip() == ivle_www:
717
725
                write_ivle_pth = False
718
 
                break
 
726
            elif line.strip() == ivle_lib:
 
727
                write_ivle_lib_pth = False
 
728
        file.close()
719
729
    except (IOError, OSError):
720
730
        pass
721
731
    if write_ivle_pth:
722
732
        action_append(ivle_pth, ivle_www)
 
733
    if write_ivle_lib_pth:
 
734
        action_append(ivle_pth, ivle_lib)
723
735
 
724
736
    return 0
725
737