In [24]:
from IPython.display import IFrame, HTML
from IPython.core.display import display, HTML
import os
In [ ]:
 
In [1]:
!ls ~/.jupyter/lab/workspaces
lab-a511.jupyterlab-workspace
labworkspaces234234-1c1f.jupyterlab-workspace
labworkspaces3123123123dfasdf-5998.jupyterlab-workspace
labworkspacesasdf-cf13.jupyterlab-workspace
labworkspacescanvas-1027.jupyterlab-workspace
labworkspacesdrawiocsv-6e9a.jupyterlab-workspace
labworkspacesflowchart-hex-3cee.jupyterlab-workspace
labworkspacesgraphviz-28ab.jupyterlab-workspace
labworkspaceskubeflow-e136.jupyterlab-workspace
labworkspacesmap-1cb3.jupyterlab-workspace
labworkspacesmaster-89f0.jupyterlab-workspace
labworkspacesnbviewer-bd35.jupyterlab-workspace
labworkspacesprom-ccb8.jupyterlab-workspace
labworkspacespygo-8167.jupyterlab-workspace
labworkspacesspam-73df.jupyterlab-workspace
labworkspacessvg-73bd.jupyterlab-workspace
labworkspacestestpng-324234-41a8.jupyterlab-workspace
labworkspacestestpng-b8e9.jupyterlab-workspace
In [2]:
workspaces = ! ls ~/.jupyter/lab/workspaces
wks = []
for wk in workspaces:
    if not "labworkspaces" in wk: continue
    *l, r = wk.replace("labworkspaces", "").replace(".jupyterlab-workspace", "").split("-")
    wks.append("-".join(l))
wks
Out[2]:
['234234',
 '3123123123dfasdf',
 'asdf',
 'canvas',
 'drawiocsv',
 'flowchart-hex',
 'graphviz',
 'kubeflow',
 'map',
 'master',
 'nbviewer',
 'prom',
 'pygo',
 'spam',
 'svg',
 'testpng-324234',
 'testpng']
In [88]:
import urllib.parse
def list_workspaces():
    workspaces = ! ls ~/.jupyter/lab/workspaces
    wks = []
    for wk in workspaces:
        if not "labworkspaces" in wk: continue
        *l, r = wk.replace("labworkspaces", "").replace(".jupyterlab-workspace", "").split("-")
        wks.append("-".join(l))
    html = """
    <ul>
    {li}
    </ul>
    """.format(li="\n".join(["<li><a target='_blank' href='<server:port>/lab/workspaces/{wk}'>{wk}</a></li>".format(wk=wk) for wk in wks]))
    display(HTML(html))
In [89]:
list_workspaces()
In [ ]:
IFrame
In [ ]: