#!/usr/bin/env python
# -*- coding: utf-8 -*-

###############################################################################
#  Copyright Kitware Inc.
#
#  Licensed under the Apache License, Version 2.0 ( the "License" );
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
###############################################################################

try:
    from .base import *  # noqa
except ImportError as exc:
    # If our import failed because either girder or a girder plugin is
    # unavailable, log it and start anyway (we may be running in a girder-less
    # environment).
    import logging as logger
    logger.getLogger().setLevel(logger.INFO)
    logger.debug('Girder is unavailable.  Run as a girder plugin for girder '
                 'access.')
    girder = None

#!/usr/bin/env python
# -*- coding: utf-8 -*-

###############################################################################
#  Copyright Kitware Inc.
#
#  Licensed under the Apache License, Version 2.0 ( the "License" );
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
###############################################################################

try:
    import girder
    # This should include all of the explicitly required Girder plugins.
    import girder.plugins.worker
except ImportError:
    # If our import failed because either girder or a girder plugin is
    # unavailable, log it and start anyway (we may be running in a girder-less
    # environment).
    import logging as logger
    logger.getLogger().setLevel(logger.INFO)
    logger.debug('Girder is unavailable.  Run as a girder plugin for girder '
                 'access.')
    girder = None
else:
    # if girder is available, and we fail to import anything else, girder will
    # show the failure
    from .base import load  # noqa

Allow girder to show load errors in more cases.
Allow girder to show load errors in more cases.

If girder is installed but requirements of large_image are not, the
plugin would report as enabled but not be functional.  This checks if
girder is available, and, if so, allows girder to report errors.

Eventually, it will be nice to separate large_image without girder from
the necessary girder parts to make this easier to manage.  For now, this
should make diagnosis easier.

As a simple test, when everything works under girder, uninstall a
required module (cachetools, for instance), and restart girder.  Before,
no error was reported.  With this change, the missing module is
reported.
