Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested try/except on _load_jupyter_server_extension discovery #213

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,31 +1605,34 @@ def load_server_extensions(self):
"loaded".format(extension_name=extension.extension_name)
)
# Find the extension loading function.
func = None
try:
# This function was prefixed with an underscore in in v1.0
# because this shouldn't be a public API for most extensions.
func = getattr(extension, '_load_jupyter_server_extension')
func(self)
self.log.debug(log_msg)
except AttributeError:
# For backwards compatibility, we will still look for non
# underscored loading functions.
func = getattr(extension, 'load_jupyter_server_extension')
try:
# For backwards compatibility, we will still look for non
# underscored loading functions.
func = getattr(extension, 'load_jupyter_server_extension')
warn_msg = _(
"{extkey} is enabled. "
"`load_jupyter_server_extension` function "
"was found but `_load_jupyter_server_extension`"
"is preferred.".format(extkey=extkey)
)
self.log.warning(warn_msg)
except AttributeError:
warn_msg = _(
"{extkey} is enabled but no "
"`_load_jupyter_server_extension` function "
"was found.".format(extkey=extkey)
)
self.log.warning(warn_msg)
if func:
func(self)
warn_msg = _(
"{extkey} is enabled. "
"`load_jupyter_server_extension` function "
"was found but `_load_jupyter_server_extension`"
"is preferred.".format(extkey=extkey)
)
self.log.warning(warn_msg)
except AttributeError:
warn_msg = _(
"{extkey} is enabled but no "
"`_load_jupyter_server_extension` function "
"was found.".format(extkey=extkey)
)
self.log.warning(warn_msg)
self.log.debug(log_msg)


def init_mime_overrides(self):
# On some Windows machines, an application has registered incorrect
Expand Down