Skip to main content

Report urgency of package upgrades

Project description

siun

PyPI - Version PyPI - Python Version


Table of Contents

Usage

The most basic way to use siun is to simply run the check command:

siun check

Check command

The check command runs a configurable console command to find which packages can be updated and checks them against various criteria to determine how urgent it is to apply those updates.

Options

The check command supports a few options:

  • --quiet: Suppress regular output; Useful if you only want to update the cache file
  • --no-update: Don't refresh available updates, only read from cache if available
  • --no-cache: Don't read or write cache file
  • --output-format: Pick output format for urgency report; Available formats are [plain|fancy|json|i3status|custom]

Installation

pip install siun

Install dev env

pip install -e .[dev]

Configuration

Configuration happens through a toml file.

The default configuration looks like this:

# command which returns list of available updates
cmd_available = "pacman -Quq; if [ $? == 1 ]; then :; fi"  # pacman returns exit code 1 if there are no updates
# weight required to consider updates to be of available, warning, or critical level
thresholds = { available = 1, warning = 2, critical = 3 }
# minimum age of cached update state before it will be refreshed
cache_min_age_minutes = 30
# Custom output format - use with `--output-format=custom`
custom_format = "$status_text: $available_updates"

[criteria]
# setting for `critical` criterion
critical_pattern = "^archlinux-keyring$|^linux$|^pacman.*$"
# weight the criterion contributes to urgency score
critical_weight = 1
# setting for `count` criterion
count_threshold = 10
# setting weight to 0 disables check
count_weight = 0
# setting for `last_pacman_update` criterion
last_pacman_update_age_hours = 618  # 7 days
last_pacman_update_weight = 1

Criteria

siun checks various criteria to determine how urgent updates are. Each criterion has a weight which contributes to a total score. This score is then compared to a list of thresholds to determine wheter updates are available, recommended or required.

Built-in criteria

The following criteria are built-in:

  • available: Any updates are available
  • count: Number of available updates exceeds threshold
  • critical: Any of the available updates is considered a critical package
  • lastupdate: Time since last update has exceeded threshold

Custom criteria

You can also define your own criteria as Python code. Any python file in $XDG_CONFIG_DIR/siun/criteria will be checked for a class called SiunCriterion and run its is_fulfilled method.

Example custom criterion checking if any available updates are reported by arch-audit:

import subprocess


class SiunCriterion:
    """Custom criterion."""

    def is_fulfilled(self, criteria_settings: dict, available_updates: list):
        """Check if any available updates are in arch-audit list."""
        audit_packages = []
        arch_audit_run = subprocess.run(
            ["/usr/bin/arch-audit", "-q", "-u"],
            check=True,
            capture_output=True,
            text=True,
        )
        audit_packages = arch_audit_run.stdout.splitlines()

        return bool(set(available_updates) & set(audit_packages))

Custom output format

It's possible to define your own output format by setting a custom_format in the configuration file, and passing --output-format=custom to the siun check call. See Configuration.

Available format variables:

  • $available_updates: Comma-separated list of available updates
  • $last_update: Date and time of last time siun checked for updates in ISO format
  • $matched_criteria: Comma-separated names of matched criteria
  • $matched_criteria_short: Comma-separated matched criteria, shortened to 2 characters
  • $score: Sum weight of matched criteria
  • $status_text: Text representation of update status, e.g. "Updates available"
  • $update_count: Number of available updates

License

siun is distributed under the terms of the MIT license.

Name

siun stands for, and tries to answer, the question "Should I upgrade now?".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

siun-1.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

siun-1.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file siun-1.1.0.tar.gz.

File metadata

  • Download URL: siun-1.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for siun-1.1.0.tar.gz
Algorithm Hash digest
SHA256 538d0de53a52dff3e6c9bfe81f0c2bb0ef5396f8aa27f858e43aa6aa6fc032c2
MD5 406843db3fd8cfd47bdeae2c058fe43c
BLAKE2b-256 4d3ab1e27861545ee8e0d97ecaa35db83e83582300b28f130eb5a397ab188e9e

See more details on using hashes here.

File details

Details for the file siun-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: siun-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for siun-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eceb0b1388d599d0173bc8d655bbc8787e76b5eaa0ef760e79035c808dbb1a2c
MD5 4b44102f340f55341c43e83f1ab80044
BLAKE2b-256 f9d6297ab4e1213bb5f381f9449b8ae57262b9e30e9c8b291895c72e6acc5171

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page