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.2.0.tar.gz (24.8 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.2.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: udisks_monitor-0.2.0.tar.gz
  • Upload date:
  • Size: 24.8 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.2.0.tar.gz
Algorithm Hash digest
SHA256 c7aa2be3c40fd9fe4d87bfe6bcbc070d337c5ff52bd113da1dc712f2f09ab124
MD5 ebe76ed2eca8c9637b142d35049760f6
BLAKE2b-256 95dba8577e6817e65ee076f139e93ccf79346d658c390d02fb677004460edf0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for udisks_monitor-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: udisks_monitor-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eac00e4f3b9fb8a1964bfe1f60c4b885b30b3e7967f50e2db1929220e1e5cd59
MD5 3551b569640deff0139acaa4a7e2b606
BLAKE2b-256 7f0996bdb74a31444df88c1a8e95dde0f5b6c558098385f80b1bab4d0208a90d

See more details on using hashes here.

Provenance

The following attestation bundles were made for udisks_monitor-0.2.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