Esempio n. 1
0
File: app.py Progetto: haje01/wzdat
def dashboard():
    logging.debug("dashboard home")
    projname, dev, cache_time = _page_common_vars()

    from wzdat.util import iter_dashboard_notebook
    iport = int(cfg["host_ipython_port"])
    base_url = 'http://%s:%d/tree' % (HOST, iport)
    nbdir = get_notebook_dir()
    groups = defaultdict(list)
    for nbpath, mip in iter_dashboard_notebook(nbdir):
        logging.debug(u"dashboard notebook {}".format(nbpath))
        sdir = os.path.dirname(nbpath).replace(nbdir, '')[1:]
        fn = os.path.basename(nbpath)
        url = os.path.join(base_url, sdir, fn)
        fname = os.path.splitext(os.path.basename(nbpath))[0]
        dashbrd_info = mip['dashboard']
        if isinstance(dashbrd_info, dict):
            gk = dashbrd_info['group'].decode('utf8')
            groups[gk].append((nbpath, url, fname))
        else:
            groups[''].append((nbpath, url, fname))
    logging.debug("collected notebooks by group")

    gnbs = []
    for gk in sorted(groups.keys()):
        if gk != '':
            _collect_gnbs(gnbs, gk, groups)
    if '' in groups:
        _collect_gnbs(gnbs, '', groups)
    logging.debug("done _collect_gnbs")

    return render_template("dashboard.html", cur="dashboard",
                           projname=projname, notebooks=gnbs,
                           nb_url=base_url, dev=dev, cache_time=cache_time)
Esempio n. 2
0
def test_notebook_dashboard(fxsoldir):
    nbdir = get_notebook_dir()
    dnbs = [nbpath for nbpath in iter_dashboard_notebook(nbdir)]
    assert len(dnbs) == 5