Skip to content

Commit

Permalink
Catch error when querying kernel with invalid token
Browse files Browse the repository at this point in the history
  • Loading branch information
thangleiter committed Jun 23, 2020
1 parent b7ae604 commit 9981fe2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions filter_functions/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,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 9981fe2

Please sign in to comment.