Skip to content

Commit

Permalink
Merge pull request #310 from takluyver/get-all-specs-tolerant
Browse files Browse the repository at this point in the history
Tolerate invalid kernel specs in get_all_specs()
  • Loading branch information
Carreau authored Dec 15, 2017
2 parents adb8335 + ed05107 commit cf36849
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions jupyter_client/kernelspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,17 @@ def get_all_specs(self):
}
"""
d = self.find_kernel_specs()
return {kname: {
"resource_dir": d[kname],
"spec": self._get_kernel_spec_by_name(kname, d[kname]).to_dict()
} for kname in d}
res = {}
for kname, resource_dir in d.items():
try:
spec = self._get_kernel_spec_by_name(kname, resource_dir)
res[kname] = {
"resource_dir": resource_dir,
"spec": spec.to_dict()
}
except Exception:
self.log.warning("Error loading kernelspec %r", kname, exc_info=True)
return res

def remove_kernel_spec(self, name):
"""Remove a kernel spec directory by name.
Expand Down

0 comments on commit cf36849

Please sign in to comment.