Skip to main content

Event-driven pub/sub wrapper around udisksctl monitor (Linux)

Project description

udisks-monitor

Event-driven pub/sub wrapper around udisksctl monitor (Linux).

PyPI version Python License OS

CI codecov

Downloads total Downloads/month Downloads/week

One lightweight dependency (strip-ansi). Parses the human-readable output of udisksctl monitor into typed event dataclasses with wall-clock timestamps, dispatching to subscribers via an in-process event bus.

Install

pip install udisks-monitor

Quickstart

from udisks_monitor import UdisksMonitor, DevicePropertyChanged, JobProperties

mon = UdisksMonitor()

# Subscribe by event type and filter
@mon.on(DevicePropertyChanged, device='loop0', property_='BackingFile')
def on_backing(evt):
    if not evt.value:
        print(f"{evt.device_name} detached")

@mon.on(JobProperties, operation='filesystem-mount')
def on_mount(evt):
    print(f"mount job for {evt.objects}")

mon.start()
mon.join()

Events

Event When
DevicePropertyChanged A property on any device interface changed
InterfaceAdded A D-Bus interface appeared on a device
InterfaceRemoved A D-Bus interface was removed
JobAdded A UDisks2 job was created
JobProperties The operation and target objects of a job
JobCompleted A job finished (success/failure)
JobRemoved A job object was torn down

All events carry a timestamp: str field with the HH:MM:SS.mmm wall-clock time from udisksctl monitor.

Subscription filters

bus = EventBus()

# By event type
bus.subscribe(fn, event_type=DevicePropertyChanged)

# By operation string (matches JobProperties with that operation)
bus.subscribe(fn, event_type='filesystem-mount')

# By device name
bus.subscribe(fn, device='loop0')

# By D-Bus interface
bus.subscribe(fn, interface='org.freedesktop.UDisks2.Loop')

# By property name
bus.subscribe(fn, property_='BackingFile')

# Combined
bus.subscribe(fn,
    event_type=DevicePropertyChanged,
    device='loop0',
    property_='MountPoints')

# Decorator style
@bus.on(DevicePropertyChanged, device='loop0', property_='BackingFile')
def handler(evt): ...

Nix

{
  inputs.udisks-monitor.url = "github:MBanucu/udisks-monitor";
}

License

GPL-3.0-only

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

udisks_monitor-0.3.0.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

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

udisks_monitor-0.3.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file udisks_monitor-0.3.0.tar.gz.

File metadata

  • Download URL: udisks_monitor-0.3.0.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for udisks_monitor-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7aa1464fa37c1dc20ca995a6679f07774a2d6a887e8d8e8aa6a819e6d40199de
MD5 50814cb6f60a6076f07fcf93d32cee83
BLAKE2b-256 791f21244d744e4c3c974758a064851da584b96922811dd3a809831272ec4e19

See more details on using hashes here.

Provenance

The following attestation bundles were made for udisks_monitor-0.3.0.tar.gz:

Publisher: publish.yml on MBanucu/udisks-monitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file udisks_monitor-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: udisks_monitor-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for udisks_monitor-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 933d99c2afa733a807631f29e930a9b85d2aec346172c3c92c0fd0db66da118c
MD5 b1beb33bc2bd0ee200a500843a309d3a
BLAKE2b-256 5f4f356f0072a71512b4b5e8baf02cb1916e159c4436b98cfe34bed06762fdbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for udisks_monitor-0.3.0-py3-none-any.whl:

Publisher: publish.yml on MBanucu/udisks-monitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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