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).

Zero dependencies. Parses the human-readable output of udisksctl monitor into typed event dataclasses and dispatches them 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

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.1.0.tar.gz (11.3 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.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: udisks_monitor-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 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.1.0.tar.gz
Algorithm Hash digest
SHA256 daae8e724f4e33e2a6c81557df59840064374781dacb85dfa90dbd0eb3d6f7fc
MD5 7f8f77a2ec94a146422dc439bd9aef9a
BLAKE2b-256 b0920caba3fa980c17d483a3e9c9576c5a0e9d13387eccde1121c6e57b11996f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: udisks_monitor-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 309f085c46bda9392117296c1137b4fcfafaf59d8eddf8cb025bc84fe29c11d7
MD5 a6f24422851e723b3e6b3e16ea270be8
BLAKE2b-256 b830a459eda65665766c6a13da638b397fe992bf5b68851576d0bd29236d6ee6

See more details on using hashes here.

Provenance

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