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

« back to all changes in this revision

Viewing changes to setup/util.py

Merge from new-dispatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
           'action_symlink', 'action_append', 'action_chown',
38
38
           'action_chown_setuid', 'action_chmod_x', 'action_make_private',
39
39
           'query_user', 'filter_mutate', 'get_svn_revision', 'InstallList',
40
 
           'wwwuid']
 
40
           'make_install_path', 'wwwuid']
41
41
 
42
42
# Determine which Python version (2.4 or 2.5, for example) we are running,
43
43
# and use that as the filename to the Python directory.
292
292
installlist_mimetypes = ['text/x-python', 'text/html',
293
293
    'application/x-javascript', 'application/javascript',
294
294
    'text/css', 'image/png', 'image/gif', 'application/xml']
 
295
# Filenames which will automatically be placed in the list by InstallList.
 
296
whitelist_filenames = ['ivle-spec.conf']
295
297
 
296
298
def build_list_py_files(dir, no_top_level=False):
297
299
    """Builds a list of all py files found in a directory and its
305
307
        filter_mutate(lambda x: x[0] != '.', dirnames)
306
308
        # All *.py files are added to the list
307
309
        pylist += [os.path.join(dirpath, item) for item in filenames
308
 
            if mimetypes.guess_type(item)[0] in installlist_mimetypes]
 
310
            if mimetypes.guess_type(item)[0] in installlist_mimetypes or
 
311
               item in whitelist_filenames]
309
312
    if no_top_level:
310
313
        for i in range(0, len(pylist)):
311
314
            _, pylist[i] = pylist[i].split(os.sep, 1)
312
315
    return pylist
313
316
 
 
317
def make_install_path(rootdir, path):
 
318
    '''Combine an installation root directory and final install path.
 
319
 
 
320
    Normalises path, and joins it to the end of rootdir, removing the leading
 
321
    / to make it relative if required.
 
322
    '''
 
323
    normpath = os.path.normpath(path)
 
324
    if normpath.startswith(os.sep):
 
325
        normpath = normpath[1:]
 
326
    return os.path.join(rootdir, normpath)
 
327
 
314
328
class InstallList(object):
315
329
    # We build two separate lists, by walking www and console
316
330
    list_www = property(lambda self: build_list_py_files('www'))
331
345
        "services/usrmgt-server",
332
346
        "services/diffservice",
333
347
        "services/svnlogservice",
 
348
        "services/usrmgt-server", # XXX: Should be in bin/
334
349
    ]
335
350
 
336
351
    list_user_binaries = [
342
357
        "bin/ivle-mountallusers",
343
358
        "bin/ivle-remakeuser",
344
359
        "bin/ivle-showenrolment",
 
360
        "bin/ivle-buildjail",
345
361
    ]