def pack_custom():
    app = get_app()
    base = apath(app, r=request)
    if request.post_vars.file:
        files = request.post_vars.file
        files = [files] if not isinstance(files,list) else files
        fname = 'web2py.app.%s.w2p' % app
        try:
            filename = app_pack(app, request, raise_ex=True, filenames=files)
        except Exception, e:
            filename = None
        if filename:
            response.headers['Content-Type'] = 'application/w2p'
            disposition = 'attachment; filename=%s' % fname
            response.headers['Content-Disposition'] = disposition
            return safe_read(filename, 'rb')
        else:
            session.flash = T('internal error: %s', e)
            redirect(URL(args=request.args))
    def ignore(fs):
        return [f for f in fs if not (
                f[:1] in '#' or f.endswith('~') or f.endswith('.bak'))]
    files = {}
    for (r,d,f) in os.walk(base):
        files[r] = {'folders':ignore(d),'files':ignore(f)}
    return locals()
dataset/ETHPy150Open uwdata/termite-data-server/web2py/applications-original/admin/controllers/default.py/pack_custom/original