pysnt.setup_utils module#
Setup utilities for PySNT.
This module provides helper functions for setting up PySNT, including Fiji path configuration and environment setup with persistent configuration storage.
- get_config_dir() Path[source]#
Get platform-specific config directory.
- Returns:
Platform-specific configuration directory for pysnt (following XDG base directory specification)
- Return type:
- load_config() Dict[str, Any][source]#
Load configuration from platform-specific config file.
- Returns:
Configuration dictionary, empty if file doesn’t exist or is invalid
- Return type:
Dict[str, Any]
- save_config(config: Dict[str, Any]) bool[source]#
Save configuration to platform-specific config file.
- Parameters:
config (Dict[str, Any]) – Configuration dictionary to save
- Returns:
True if saved successfully, False otherwise
- Return type:
bool
- set_fiji_path(fiji_path: str, validate: bool = True) bool[source]#
Set and persist the Fiji installation path.
- Parameters:
fiji_path (str) – Path to Fiji installation
validate (bool, default True) – Whether to validate the path before saving
- Returns:
True if path was set successfully, False otherwise
- Return type:
bool
Examples
>>> # Set Fiji path >>> pysnt.setup_utils.set_fiji_path("/Applications/Fiji.app") >>> >>> # Set without validation (use with caution) >>> pysnt.setup_utils.set_fiji_path("/custom/fiji/path", validate=False)
- get_fiji_path() str | None[source]#
Get the currently configured Fiji path.
Returns the path from the first available source in priority order: 1. FIJI_PATH environment variable 2. Config file 3. None if not found
- Returns:
Current Fiji path if configured, None otherwise
- Return type:
str or None
Examples
>>> # Check current Fiji path >>> path = pysnt.setup_utils.get_fiji_path() >>> if path: ... print(f"Fiji configured at: {path}") ... else: ... print("Fiji path not configured")
- clear_fiji_path(reset_env: bool = False) bool[source]#
Clear the saved Fiji path from configuration.
- Parameters:
reset_env (bool, default False) – If True, also clears the FIJI_PATH environment variable for the current session. If False, only clears the saved configuration file.
- Returns:
True if cleared successfully, False otherwise
- Return type:
bool
Examples
>>> # Clear saved Fiji path only >>> pysnt.setup_utils.clear_fiji_path() >>> >>> # Clear both saved path and environment variable >>> pysnt.setup_utils.clear_fiji_path(reset_env=True)
- reset_fiji_path() bool[source]#
Completely reset Fiji path configuration.
This clears both the saved configuration file and the FIJI_PATH environment variable for the current session.
- Returns:
True if reset successfully, False otherwise
- Return type:
bool
Examples
>>> # Completely reset Fiji configuration >>> pysnt.setup_utils.reset_fiji_path()
- get_config_info() Dict[str, Any][source]#
Get information about the current configuration.
- Returns:
Dictionary containing configuration information
- Return type:
Dict[str, Any]
Examples
>>> # Get config info >>> info = pysnt.setup_utils.get_config_info() >>> print(f"Config directory: {info['config_dir']}") >>> print(f"Config file exists: {info['config_exists']}") >>> print(f"Fiji path: {info['fiji_path']}")
- is_fiji_valid() bool[source]#
Quick check if the current Fiji configuration is valid with SNT plugin.
- Returns:
True if Fiji is configured with SNT plugin, False otherwise
- Return type:
bool
Examples
>>> # Quick validation check >>> if not pysnt.setup_utils.is_fiji_valid(): ... print("Fiji with SNT not configured properly!") ... exit(1) >>> >>> # Use in scripts >>> import sys >>> import pysnt.setup_utils as setup >>> if not setup.is_fiji_valid(): ... print("Error: Fiji installation not found or SNT plugin missing") ... print("Run: python -m pysnt.setup_utils --auto-detect") ... sys.exit(1)
- get_fiji_status() Dict[str, Any][source]#
Get detailed status of the current Fiji configuration/
- Returns:
Dictionary with detailed status information including: - configured: bool - Whether any Fiji path is configured - path: str or None - The effective Fiji path - exists: bool - Whether the path exists - valid: bool - Whether it’s a valid Fiji installation with SNT - issues: List[str] - List of any issues found (including SNT-specific)
- Return type:
Dict[str, Any]
Examples
>>> # Get detailed status >>> status = pysnt.setup_utils.get_fiji_status() >>> if not status['valid']: ... print(f"Fiji/SNT issues: {', '.join(status['issues'])}")
- show_config_status()[source]#
Display current Fiji configuration status in a user-friendly format.
Examples
>>> # Show current configuration >>> pysnt.setup_utils.show_config_status()
- auto_detect_and_configure() str | None[source]#
Try to auto-detect a valid Fiji installation and save to config if found.
- Returns:
Path to detected Fiji installation if found and configured, None otherwise
- Return type:
str or None
Examples
>>> # Auto-detect and configure Fiji >>> path = pysnt.setup_utils.auto_detect_and_configure() >>> if path: ... print(f"Fiji configured at: {path}") ... else: ... print("No Fiji installation detected")
- setup_fiji_environment(fiji_path: str, permanent: bool = False) bool[source]#
Set up Fiji environment variable.
- Parameters:
fiji_path (str) – Path to Fiji installation
permanent (bool, default False) – Whether to attempt permanent setup (adds to shell profile)
- Returns:
True if setup was successful
- Return type:
bool
- find_fiji_installations() List[str][source]#
Search for Fiji installations on the system.
- Returns:
List of found Fiji installation paths
- Return type:
List[str]
- check_fiji_installation(fiji_path: str) dict[source]#
Check and validate a Fiji installation serving SNT.
- Parameters:
fiji_path (str) – Path to check
- Returns:
Dictionary with validation results including: - path: str - The path that was checked - exists: bool - Whether the path exists - is_fiji: bool - Whether it appears to be a Fiji installation - has_snt: bool - Whether SNT plugin is found - executables: List[str] - Found executables - has_plugins: bool - Whether plugins directory exists - has_jars: bool - Whether jars directory exists - snt_jars: List[str] - Found SNT jar files - issues: List[str] - List of issues found
- Return type:
dict