Skip to content

Commit

Permalink
Merge pull request #4 from ColCarroll/warn-ipykernel
Browse files Browse the repository at this point in the history
Warn if missing ipykernel
  • Loading branch information
ColCarroll committed Nov 7, 2017
2 parents a04ca3e + daf851f commit eb294dd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions callisto/callisto.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import shutil
import subprocess

import click
from jupyter_client import kernelspec
Expand Down Expand Up @@ -50,6 +51,9 @@ def cli(name, path, list, delete):
fg='green')
click.secho(json.dumps(kernel, indent=2))
click.secho('See {} to edit.'.format(kernel_path), fg='green')
if need_to_install_ipykernel():
click.secho('Remember to install ipykernel before starting a jupyter notebook!',
fg='red')
else:
click.secho('Failed to install a new jupyter kernel "{display_name}".\n'
'See {kernel_path} to confirm it isn\'t already there.'.format(
Expand Down Expand Up @@ -149,3 +153,12 @@ def confirm_kernel_path_is_safe(kernel_path):
if not os.path.isdir(directory):
os.makedirs(directory)
return True


def need_to_install_ipykernel():
"""Check if ipykernel is installed"""
status = subprocess.call(['python', '-c', 'import ipykernel'],
stderr=subprocess.STDOUT,
stdout=open(os.devnull, 'w'),
close_fds=True)
return status == 0

0 comments on commit eb294dd

Please sign in to comment.