Пример #1
0
def compile_dir(dir,force=0, **keywords):
    global debug
    global verbosity
    global errors_are_fatal
    key = os.getpid()
    debug[key] = 0
    verbosity[key] = 1
    errors_are_fatal[key] = 0
    map_globals = {'debug':debug,
                   'verbosity':verbosity,
                   'errors_are_fatal':errors_are_fatal}
    try:
        keys = keywords.keys()
        for keyword in ('debug','verbosity','errors_are_fatal'):
            if keywords.has_key(keyword):
                keys.remove(keyword)
                map_globals[keyword][key] = keywords[keyword]
        if keys:
            raise TypeError,\
                  'compile_dir() got an unexpected keyword argument %s' % \
                  keys[0]
        compile_dir_and_recurse(dir,0,force)
        compileall.compile_dir(dir,ddir=os.path.basename(dir),force=force)
    finally:
        del debug[key]
        del verbosity[key]
        del errors_are_fatal[key]
Пример #2
0
def compile_dir_and_recurse(dir,level,force):
    global debug
    global verbosity
    global errors_are_fatal
    pid = os.getpid()
    os.chdir(dir)
    if force:
        if verbosity[pid] > 1:
            v = 'v'
        else:
            v = ''
        os.system("rm -%sf *.so *.o *.pyc" % v)
    flist = os.listdir('.')
    if 'compile' in flist:
        os.system(os.path.realpath('./compile'),
                  errors_are_fatal=errors_are_fatal[pid],
                  verbosity=verbosity[pid],
                  debug=debug[pid])
    for f in flist:
        pathname = os.path.join(dir,f)
        if f in ('CVS', 'penvironment.d'):
            continue
        try:
            mode = os.stat(pathname)[ST_MODE]
            if S_ISDIR(mode) and f[0] != '.':
                compile_dir_and_recurse(pathname,level+1,force)
                os.chdir(dir)
        except OSError, e:
            if verbosity[pid] > 1:
                print "WARNING:  Skipping", pathname, "due to", e