def app_install(app, fobj, request, filename, overwrite=None):
    """Installs an application:

    - Identifies file type by filename
    - Writes `fobj` contents to the `../deposit/` folder
    - Calls `w2p_unpack()` to do the job.

    Args:
        app(str): new application name
        fobj(obj): file object containing the application to be installed
        request: the global request object
        filename(str): original filename of the `fobj`,
            required to determine extension
        overwrite(bool): force overwrite of existing application

    Returns:
        name of the file where app is temporarily stored or `None` on failure

    """
    did_mkdir = False
    if filename[-4:] == '.w2p':
        extension = 'w2p'
    elif filename[-7:] == '.tar.gz':
        extension = 'tar.gz'
    else:
        extension = 'tar'
    upname = apath('../deposit/%s.%s' % (app, extension), request)

    try:
        write_file(upname, fobj.read(), 'wb')
        path = apath(app, request)
        if not overwrite:
            os.mkdir(path)
            did_mkdir = True
        w2p_unpack(upname, path)
        if extension != 'tar':
            os.unlink(upname)
        fix_newlines(path)
        return upname
    except Exception:
        if did_mkdir:
            rmtree(path)
        return False
dataset/ETHPy150Open uwdata/termite-data-server/web2py/gluon/admin.py/app_install/original