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

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: mattgiuca
  • Date: 2008-01-25 01:05:22 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:300
conf/apps: Added TutorialService as a registered app.
tutorialservice: Started writing app. Currently reads some arguments, and if
    action=test and code is provided, echoes the code back in JSON.

Show diffs side-by-side

added added

removed removed

Lines of Context:
176
176
# as necessary, and include it in the distribution.
177
177
listmake_mimetypes = ['text/x-python', 'text/html',
178
178
    'application/x-javascript', 'application/javascript',
179
 
    'text/css', 'image/png', 'application/xml']
 
179
    'text/css', 'image/png']
180
180
 
181
181
# Main function skeleton from Guido van Rossum
182
182
# http://www.artima.com/weblogs/viewpost.jsp?thread=4829
237
237
    listmake (developer use only)
238
238
    conf [args]
239
239
    build
240
 
    install [--nojail] [--nosubjects] [-n|--dry]
 
240
    install [--nojail] [-n|--dry]
241
241
"""
242
242
        return 1
243
243
    elif len(args) != 1:
293
293
 
294
294
--dry | -n  Print out the actions but don't do anything."""
295
295
    elif operation == 'install':
296
 
        print """sudo python setup.py install [--nojail] [--nosubjects][--dry|-n]
 
296
        print """sudo python setup.py install [--nojail] [--dry|-n]
297
297
(Requires root)
298
298
Create target install directory ($target).
299
299
Create $target/bin.
301
301
chown and chmod the installed trampoline.
302
302
Copy www/ to $target.
303
303
Copy jail/ to jails template directory (unless --nojail specified).
304
 
Copy subjects/ to subjects directory (unless --nosubjects specified).
305
304
 
306
 
--nojail        Do not copy the jail.
307
 
--nosubjects    Do not copy the subjects.
 
305
--nojail    Do not copy the jail.
308
306
--dry | -n  Print out the actions but don't do anything."""
309
307
    elif operation == 'updatejails':
310
308
        print """sudo python setup.py updatejails [--dry|-n]
322
320
    # We build two separate lists, by walking www and console
323
321
    list_www = build_list_py_files('www')
324
322
    list_console = build_list_py_files('console')
325
 
    list_subjects = build_list_py_files('subjects', no_top_level=True)
326
323
    # Make sure that the files generated by conf are in the list
327
324
    # (since listmake is typically run before conf)
328
325
    if "www/conf/conf.py" not in list_www:
352
349
# List of all installable files in console directory.
353
350
list_console = """)
354
351
        writelist_pretty(file, list_console)
355
 
        file.write("""
356
 
# List of all installable files in subjects directory.
357
 
# This is to install sample subjects and material.
358
 
list_subjects = """)
359
 
        writelist_pretty(file, list_subjects)
360
352
 
361
353
        file.close()
362
354
    except IOError, (errno, strerror):
373
365
 
374
366
    return 0
375
367
 
376
 
def build_list_py_files(dir, no_top_level=False):
 
368
def build_list_py_files(dir):
377
369
    """Builds a list of all py files found in a directory and its
378
 
    subdirectories. Returns this as a list of strings.
379
 
    no_top_level=True means the file paths will not include the top-level
380
 
    directory.
381
 
    """
 
370
    subdirectories. Returns this as a list of strings."""
382
371
    pylist = []
383
372
    for (dirpath, dirnames, filenames) in os.walk(dir):
384
373
        # Exclude directories beginning with a '.' (such as '.svn')
386
375
        # All *.py files are added to the list
387
376
        pylist += [os.path.join(dirpath, item) for item in filenames
388
377
            if mimetypes.guess_type(item)[0] in listmake_mimetypes]
389
 
    if no_top_level:
390
 
        for i in range(0, len(pylist)):
391
 
            _, pylist[i] = pylist[i].split(os.sep, 1)
392
378
    return pylist
393
379
 
394
380
def writelist_pretty(file, list):
616
602
 
617
603
def install(args):
618
604
    # Get "dry" and "nojail" variables from command line
619
 
    (opts, args) = getopt.gnu_getopt(args, "n",
620
 
        ['dry', 'nojail', 'nosubjects'])
 
605
    (opts, args) = getopt.gnu_getopt(args, "n", ['dry', 'nojail'])
621
606
    opts = dict(opts)
622
607
    dry = '-n' in opts or '--dry' in opts
623
608
    nojail = '--nojail' in opts
624
 
    nosubjects = '--nosubjects' in opts
625
609
 
626
610
    if dry:
627
611
        print "Dry run (no actions will be executed\n"
649
633
        # to the jails template directory (it will be used as a template
650
634
        # for all the students' jails).
651
635
        action_copytree('jail', os.path.join(jail_base, 'template'), dry)
652
 
    if not nosubjects:
653
 
        # Copy the subjects directory across
654
 
        action_copylist(install_list.list_subjects, subjects_base, dry,
655
 
            srcdir="./subjects")
656
636
 
657
637
    # Append IVLE path to ivle.pth in python site packages
658
638
    # (Unless it's already there)
788
768
    if dry: return
789
769
    common.makeuser.linktree(src, dst)
790
770
 
791
 
def action_copylist(srclist, dst, dry, srcdir="."):
 
771
def action_copylist(srclist, dst, dry):
792
772
    """Copies all files in a list to a new location. The files in the list
793
773
    are read relative to the current directory, and their destinations are the
794
774
    same paths relative to dst. Creates all parent directories as necessary.
795
 
    srcdir is "." by default, can be overridden.
796
775
    """
797
776
    for srcfile in srclist:
798
777
        dstfile = os.path.join(dst, srcfile)
799
 
        srcfile = os.path.join(srcdir, srcfile)
800
778
        dstdir = os.path.split(dstfile)[0]
801
779
        if not os.path.isdir(dstdir):
802
780
            action_mkdir(dstdir, dry)