PyObjC Framework: DiskArbitration

12.1 · active · verified Tue Apr 14

This library provides Python wrappers for Apple's DiskArbitration framework on macOS, enabling programmatic interaction with disk management, mount/unmount events, and disk information. It is part of the larger PyObjC project, currently at version 12.1, with a release cadence often synchronized with macOS SDK updates and Python version support.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the DiskArbitration framework and create a basic session. It verifies that the framework is correctly loaded and accessible, releasing the session immediately as a full-fledged DiskArbitration application typically involves event loops and callbacks.

import DiskArbitration
import CoreFoundation

# Create a DiskArbitration session
session = DiskArbitration.DASessionCreate(CoreFoundation.kCFAllocatorDefault)

if session:
    print("DiskArbitration session created successfully.")
    # In a real application, you would register callbacks, e.g., using DASessionScheduleWithRunLoop
    # For a quick demo, we just verify session creation and release it.
    CoreFoundation.CFRelease(session)
else:
    print("Failed to create DiskArbitration session.")

view raw JSON →