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

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: mattgiuca
  • Date: 2008-01-31 01:10:29 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:344
dispatch/ivle CSS foo.
The IVLE header is now a fixed height in em (previously was just intrinsic
    height).
This fixes the "tabs sometimes don't line up with the base line" display
problem, and also makes it much easier to add fixed or absolute content on the
rest of the page.

This was done by separating the tabs out into a separate div and making that
absolutely positioned. Now the header is exactly 5.3em.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
# cutting a distribution, and the listfile it generates should be included in
32
32
# the distribution, avoiding the administrator having to run it.
33
33
 
34
 
# setup.py conf [args]
 
34
# setup.py config [args]
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.
74
74
import conf
75
75
import common.makeuser
76
76
 
 
77
# Determine which Python version (2.4 or 2.5, for example) we are running,
 
78
# and use that as the filename to the Python directory.
 
79
# Just get the first 3 characters of sys.version.
 
80
PYTHON_VERSION = sys.version[0:3]
 
81
 
77
82
# Operating system files to copy over into the jail.
78
83
# These will be copied from the given place on the OS file system into the
79
84
# same place within the jail.
94
99
    '/bin/ls',
95
100
    '/bin/echo',
96
101
    # Needed by python
97
 
    '/usr/bin/python2.5',
 
102
    '/usr/bin/python%s' % PYTHON_VERSION,
98
103
    # Needed by matplotlib
99
104
    '/usr/lib/i686/cmov/libssl.so.0.9.8',
100
105
    '/usr/lib/i686/cmov/libcrypto.so.0.9.8',
118
123
]
119
124
# Symlinks to make within the jail. Src mapped to dst.
120
125
JAIL_LINKS = {
121
 
    'python2.5': 'jail/usr/bin/python',
 
126
    'python%s' % PYTHON_VERSION: 'jail/usr/bin/python',
122
127
}
123
128
# Trees to copy. Src mapped to dst (these will be passed to action_copytree).
124
129
JAIL_COPYTREES = {
125
 
    '/usr/lib/python2.5': 'jail/usr/lib/python2.5',
 
130
    '/usr/lib/python%s' % PYTHON_VERSION:
 
131
        'jail/usr/lib/python%s' % PYTHON_VERSION,
126
132
    '/usr/share/matplotlib': 'jail/usr/share/matplotlib',
127
133
    '/etc/ld.so.conf.d': 'jail/etc/ld.so.conf.d',
128
134
}
176
182
# as necessary, and include it in the distribution.
177
183
listmake_mimetypes = ['text/x-python', 'text/html',
178
184
    'application/x-javascript', 'application/javascript',
179
 
    'text/css', 'image/png']
 
185
    'text/css', 'image/png', 'application/xml']
180
186
 
181
187
# Main function skeleton from Guido van Rossum
182
188
# http://www.artima.com/weblogs/viewpost.jsp?thread=4829
214
220
    try:
215
221
        oper_func = {
216
222
            'help' : help,
217
 
            'conf' : conf,
 
223
            'config' : conf,
218
224
            'build' : build,
219
225
            'listmake' : listmake,
220
226
            'install' : install,
235
241
Operation (and args) can be:
236
242
    help [operation]
237
243
    listmake (developer use only)
238
 
    conf [args]
 
244
    config [args]
239
245
    build
240
 
    install [--nojail] [-n|--dry]
 
246
    install [--nojail] [--nosubjects] [-n|--dry]
241
247
"""
242
248
        return 1
243
249
    elif len(args) != 1:
256
262
be copied upon installation. This should be run by the developer before
257
263
cutting a distribution, and the listfile it generates should be included in
258
264
the distribution, avoiding the administrator having to run it."""
259
 
    elif operation == 'conf':
260
 
        print """python setup.py conf [args]
 
265
    elif operation == 'config':
 
266
        print """python setup.py config [args]
261
267
Configures IVLE with machine-specific details, most notably, various paths.
262
268
Either prompts the administrator for these details or accepts them as
263
269
command-line args. Will be interactive only if there are no arguments given.
293
299
 
294
300
--dry | -n  Print out the actions but don't do anything."""
295
301
    elif operation == 'install':
296
 
        print """sudo python setup.py install [--nojail] [--dry|-n]
 
302
        print """sudo python setup.py install [--nojail] [--nosubjects][--dry|-n]
297
303
(Requires root)
298
304
Create target install directory ($target).
299
305
Create $target/bin.
301
307
chown and chmod the installed trampoline.
302
308
Copy www/ to $target.
303
309
Copy jail/ to jails template directory (unless --nojail specified).
 
310
Copy subjects/ to subjects directory (unless --nosubjects specified).
304
311
 
305
 
--nojail    Do not copy the jail.
 
312
--nojail        Do not copy the jail.
 
313
--nosubjects    Do not copy the subjects.
306
314
--dry | -n  Print out the actions but don't do anything."""
307
315
    elif operation == 'updatejails':
308
316
        print """sudo python setup.py updatejails [--dry|-n]
320
328
    # We build two separate lists, by walking www and console
321
329
    list_www = build_list_py_files('www')
322
330
    list_console = build_list_py_files('console')
 
331
    list_subjects = build_list_py_files('subjects', no_top_level=True)
323
332
    # Make sure that the files generated by conf are in the list
324
333
    # (since listmake is typically run before conf)
325
334
    if "www/conf/conf.py" not in list_www:
349
358
# List of all installable files in console directory.
350
359
list_console = """)
351
360
        writelist_pretty(file, list_console)
 
361
        file.write("""
 
362
# List of all installable files in subjects directory.
 
363
# This is to install sample subjects and material.
 
364
list_subjects = """)
 
365
        writelist_pretty(file, list_subjects)
352
366
 
353
367
        file.close()
354
368
    except IOError, (errno, strerror):
365
379
 
366
380
    return 0
367
381
 
368
 
def build_list_py_files(dir):
 
382
def build_list_py_files(dir, no_top_level=False):
369
383
    """Builds a list of all py files found in a directory and its
370
 
    subdirectories. Returns this as a list of strings."""
 
384
    subdirectories. Returns this as a list of strings.
 
385
    no_top_level=True means the file paths will not include the top-level
 
386
    directory.
 
387
    """
371
388
    pylist = []
372
389
    for (dirpath, dirnames, filenames) in os.walk(dir):
373
390
        # Exclude directories beginning with a '.' (such as '.svn')
375
392
        # All *.py files are added to the list
376
393
        pylist += [os.path.join(dirpath, item) for item in filenames
377
394
            if mimetypes.guess_type(item)[0] in listmake_mimetypes]
 
395
    if no_top_level:
 
396
        for i in range(0, len(pylist)):
 
397
            _, pylist[i] = pylist[i].split(os.sep, 1)
378
398
    return pylist
379
399
 
380
400
def writelist_pretty(file, list):
602
622
 
603
623
def install(args):
604
624
    # Get "dry" and "nojail" variables from command line
605
 
    (opts, args) = getopt.gnu_getopt(args, "n", ['dry', 'nojail'])
 
625
    (opts, args) = getopt.gnu_getopt(args, "n",
 
626
        ['dry', 'nojail', 'nosubjects'])
606
627
    opts = dict(opts)
607
628
    dry = '-n' in opts or '--dry' in opts
608
629
    nojail = '--nojail' in opts
 
630
    nosubjects = '--nosubjects' in opts
609
631
 
610
632
    if dry:
611
633
        print "Dry run (no actions will be executed\n"
633
655
        # to the jails template directory (it will be used as a template
634
656
        # for all the students' jails).
635
657
        action_copytree('jail', os.path.join(jail_base, 'template'), dry)
 
658
    if not nosubjects:
 
659
        # Copy the subjects directory across
 
660
        action_copylist(install_list.list_subjects, subjects_base, dry,
 
661
            srcdir="./subjects")
636
662
 
637
663
    # Append IVLE path to ivle.pth in python site packages
638
664
    # (Unless it's already there)
639
665
    ivle_pth = os.path.join(sys.prefix,
640
 
        "lib/python2.5/site-packages/ivle.pth")
 
666
        "lib/python%s/site-packages/ivle.pth" % PYTHON_VERSION)
641
667
    ivle_www = os.path.join(ivle_install_dir, "www")
642
668
    write_ivle_pth = True
643
669
    try:
768
794
    if dry: return
769
795
    common.makeuser.linktree(src, dst)
770
796
 
771
 
def action_copylist(srclist, dst, dry):
 
797
def action_copylist(srclist, dst, dry, srcdir="."):
772
798
    """Copies all files in a list to a new location. The files in the list
773
799
    are read relative to the current directory, and their destinations are the
774
800
    same paths relative to dst. Creates all parent directories as necessary.
 
801
    srcdir is "." by default, can be overridden.
775
802
    """
776
803
    for srcfile in srclist:
777
804
        dstfile = os.path.join(dst, srcfile)
 
805
        srcfile = os.path.join(srcdir, srcfile)
778
806
        dstdir = os.path.split(dstfile)[0]
779
807
        if not os.path.isdir(dstdir):
780
808
            action_mkdir(dstdir, dry)
789
817
def action_copyfile(src, dst, dry):
790
818
    """Copies one file to a new location. Creates all parent directories
791
819
    as necessary.
 
820
    Warn if file not found.
792
821
    """
793
822
    dstdir = os.path.split(dst)[0]
794
823
    if not os.path.isdir(dstdir):
798
827
        try:
799
828
            shutil.copyfile(src, dst)
800
829
            shutil.copymode(src, dst)
801
 
        except shutil.Error:
802
 
            pass
 
830
        except (shutil.Error, IOError), e:
 
831
            print "Warning: " + str(e)
803
832
 
804
833
def action_symlink(src, dst, dry):
805
834
    """Creates a symlink in a given location. Creates all parent directories