Skip to content

Commit

Permalink
Merge 0bcc105 into b7ae604
Browse files Browse the repository at this point in the history
  • Loading branch information
thangleiter committed Jun 23, 2020
2 parents b7ae604 + 0bcc105 commit b6a2c29
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions filter_functions/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ def _list_running_servers(runtime_dir: str = None) -> Generator:
directory, and yield dicts of their information, each one pertaining to
a currently running notebook server instance.
Copied from notebook.notebookapp.list_running_servers() (version 5.7.8)
since the highest version compatible with Python 3.5 (version 5.6.0)
has a bug.
Copied from ``notebook.notebookapp.list_running_servers()``:
- Copyright (c) 2001-2015, IPython Development Team
- Copyright (c) 2015-, Jupyter Development Team
All rights reserved.
"""
if runtime_dir is None:
runtime_dir = jupyter_runtime_dir()
Expand Down Expand Up @@ -149,12 +152,16 @@ def _get_notebook_name() -> str:
response = requests.get(urljoin(ss['url'], 'api/sessions'),
params={'token': ss.get('token', '')})
for nn in json.loads(response.text):
if nn['kernel']['id'] == kernel_id:
try:
relative_path = nn['notebook']['path']
return os.path.join(ss['notebook_dir'], relative_path)
except KeyError:
return ''
try:
if nn['kernel']['id'] == kernel_id:
try:
relative_path = nn['notebook']['path']
return os.path.join(ss['notebook_dir'],
relative_path)
except KeyError:
return ''
except TypeError:
return ''

return ''

Expand Down

0 comments on commit b6a2c29

Please sign in to comment.