Fix jupyter notebook cannot be detected

This commit is contained in:
allegroai 2022-04-27 17:28:25 +03:00
parent e65b800e93
commit 8b652ebec1

View File

@ -556,10 +556,17 @@ class ScriptInfo(object):
# we can safely assume that we can import the notebook package here # we can safely assume that we can import the notebook package here
# noinspection PyBroadException # noinspection PyBroadException
try: try:
# noinspection PyPackageRequirements # noinspection PyBroadException
from notebook.notebookapp import list_running_servers try:
# noinspection PyPackageRequirements
from notebook.notebookapp import list_running_servers # <= Notebook v6
except Exception:
# noinspection PyPackageRequirements
from jupyter_server.serverapp import list_running_servers
import requests import requests
current_kernel = sys.argv[2].split(os.path.sep)[-1].replace('kernel-', '').replace('.json', '') current_kernel = sys.argv[2].split(os.path.sep)[-1].replace('kernel-', '').replace('.json', '')
# noinspection PyBroadException # noinspection PyBroadException
try: try:
server_info = next(list_running_servers()) server_info = next(list_running_servers())