Skip to content

Utilities#

pymmcore_plus.find_micromanager(return_first: bool = True) -> str | None | list[str] #

Locate a Micro-Manager folder (for device adapters).

In order, this will look for:

  1. An environment variable named MICROMANAGER_PATH
  2. A Micro-Manager* folder in the pymmcore-plus user data directory (this is the default install location when running mmcore install)

    • Windows: C:\Users\[user]\AppData\Local\pymmcore-plus\pymmcore-plus
    • macOS: ~/Library/Application Support/pymmcore-plus
    • Linux: ~/.local/share/pymmcore-plus
  3. A Micro-Manager* folder in the pymmcore_plus package directory (this is the default install location when running python -m pymmcore_plus.install)

  4. The default micro-manager install location:

    • Windows: C:/Program Files/
    • macOS: /Applications
    • Linux: /usr/local/lib

Note

This function is used by pymmcore_plus.CMMCorePlus to locate the micro-manager device adapters. By default, the output of this function is passed to setDeviceAdapterSearchPaths when creating a new CMMCorePlus instance.

Parameters:

Name Type Description Default
return_first bool, optional

If True (default), return the first found path. If False, return a list of all found paths.

True

pymmcore_plus.configure_logging(file: str | Path | None = LOG_FILE, stderr_level: int | str = DEFAULT_LOG_LEVEL, file_level: int | str = logging.DEBUG, log_to_stderr: bool = True, file_rotation: int = 40, file_retention: int = 20) -> None #

Configure logging for pymmcore-plus.

This function is called automatically once when pymmcore-plus is imported, to set up logging to stderr and a log file. You can call it again to change the logging settings.

You may also configure logging using the following environment variables:

  • PYMM_LOG_LEVEL - The log level for stderr logging. By default INFO.
  • PYMM_LOG_FILE - The path to the log file. If set to 0, false, no, or none, logging to file will be disabled.

Note

This function will clear all existing logging handlers and replace them with new ones. So be sure to pass all the settings you want to use each time you call this function.

Parameters:

Name Type Description Default
file str | Path | None

Path to logfile. May also be set with MM_LOG_FILE environment variable. If None, will not log to file. By default, logs to: Mac OS X: ~/Library/Application Support/pymmcore-plus/logs Unix: ~/.local/share/pymmcore-plus/logs Win: C:\Users\\AppData\Local\pymmcore-plus\pymmcore-plus\logs

LOG_FILE
stderr_level int | str

Level for stderr logging. One of "TRACE", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", or 5, 10, 20, 30, 40, or 50, respectively. by default "INFO".

DEFAULT_LOG_LEVEL
file_level int | str

Level for logging to file, by default "TRACE"

logging.DEBUG
log_to_stderr bool

Whether to log to stderr, by default True

True
file_rotation int

When to rollover to the next log file, in MegaBytes, by default 40.

40
file_retention int

Maximum number of log files to retain, by default 20

20