Skip to content

Instantly share code, notes, and snippets.

View eahrold's full-sized avatar

Eldon Ahrold eahrold

View GitHub Profile
@pudquick
pudquick / mount_shares.py
Last active March 7, 2021 16:27
Programmatically mount shares in OS X via python without the need for AppleScript
# This actually uses the same API call (NetFSMountURLSync) that AppleScript uses :D
# Note: As written, requires OS X 10.10+ / pyobjc 2.5.1+
import objc, CoreFoundation
from ctypes import c_void_p, pointer, cast
# The only reason I'm doing this the XML way is because I don't have a better way (yet)
# for correcting a function signature -after- it's already been imported.
# The problem is the last argument is a pointer to a CFArrayRef, which works out to a
# pointer to a pointer to a CFArray. pyobjc doesn't hadnle that much abstraction, so I created