Skip to content

Commit

Permalink
Nested try/except on _load_jupyter_server_extension discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
echarles committed Apr 27, 2020
1 parent 7dbc701 commit fd04222
Showing 1 changed file with 22 additions and 19 deletions.
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

0 comments on commit fd04222

Please sign in to comment.