debloat_browser_installation

Path: /debloat_components/debloat_browser_installation.py

Overview

This component installs a user-selected browser via Chocolatey on Windows. It loads the user's choice from a temporary JSON file, ensures Chocolatey is installed, and then invokes Chocolatey to install the specified browser package.

Purpose & Use Cases

Automate the installation of a preferred browser during a Windows setup or debloat workflow.

Ensure Chocolatey is present and up-to-date before installing software in a scripted environment.

Dependencies

utilities.util_logger for logging

utilities.util_error_popup for user-facing error dialogs

utilities.util_powershell_handler for running PowerShell commands

Chocolatey (will be installed if not present)

Configuration & Parameters

Parameter Type Description Default
browser_choice_path string Path to the JSON file containing the selected browser identifier. %TEMP%/talon/browser_choice.json
pkg_id string Chocolatey package ID for the browser to install (loaded from JSON).

Usage Example

python debloat_browser_installation.py

Behavior & Implementation

On execution, the script calls load_choice() to read browser_choice.json and determine the pkg_id. It then calls ensure_chocolatey(), which runs a PowerShell command to install Chocolatey if it's not detected. Next, install_browser(pkg_id) locates the choco.exe executable and invokes choco install <pkg_id> -y. All operations are logged via util_logger, and on success it logs confirmation messages. Side effects include installing system software and modifying execution policy.

Error Handling

Each step is wrapped in try/except. On failure, errors are logged at the error level, a popup is shown via util_error_popup, and the process exits with sys.exit(1).

Security Considerations

Requires administrative privileges to install Chocolatey and software. Execution policy is bypassed for script installation, so ensure the source of the Chocolatey install script and browser packages is trusted. Input JSON is loaded without validation beyond presence—ensure it is not tampered with.

Logging

Uses logger.info for normal operation (e.g., “Chocolatey already installed.”, “Installing browser via Chocolatey: <pkg_id>”). Uses logger.error for failures (e.g., “Failed to install browser 'firefox': exit code 1”).

Testing & Validation

To test, create a browser_choice.json in %TEMP%/talon/ with a valid {"browser": "firefox"}, then run the script and verify Chocolatey and Firefox are installed and logs indicate success. Validate error popups by supplying an invalid package name.

Author

Author: Raven Development Team