File: broker_util.py

package info (click to toggle)
microsoft-authentication-library-for-python 1.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,320 kB
  • sloc: python: 8,613; xml: 2,783; sh: 27; makefile: 19
file content (21 lines) | stat: -rw-r--r-- 631 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import logging


logger = logging.getLogger(__name__)


def is_pymsalruntime_installed() -> bool:
    try:
        import pymsalruntime
        logger.info("PyMsalRuntime installed and initialized")
        return True
    except ImportError:
        logger.info("PyMsalRuntime not installed")
        return False
    except RuntimeError:
        logger.warning(
            "PyMsalRuntime installed but failed to initialize the real broker. "
            "This may happen on Mac and Linux where broker is not built-in. "
            "Test cases shall attempt broker and test its fallback behavior."
        )
        return True